Skip to content

Commit

Permalink
Draft: Fixed polygon center snap
Browse files Browse the repository at this point in the history
  • Loading branch information
yorikvanhavre committed Dec 3, 2014
1 parent c6f1132 commit a6563fb
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/Mod/Draft/DraftSnap.py
Expand Up @@ -292,7 +292,9 @@ def cstr(point):
snaps.append([b,'endpoint',self.toWP(b)])

elif obj.isDerivedFrom("Part::Feature"):

if Draft.getType(obj) == "Polygon":
# special snapping for polygons: add the center
snaps.extend(self.snapToPolygon(obj))

if (not self.maxEdges) or (len(obj.Edges) <= self.maxEdges):
Expand Down Expand Up @@ -768,14 +770,15 @@ def snapToIntersection(self,shape):
def snapToPolygon(self,obj):
"returns a list of polygon center snap locations"
snaps = []
c = obj.Placement.Base
for edge in obj.Shape.Edges:
p1 = edge.Vertexes[0].Point
p2 = edge.Vertexes[-1].Point
v1 = p1.add((p2-p1).scale(.25,.25,.25))
v2 = p1.add((p2-p1).scale(.75,.75,.75))
snaps.append([v1,'center',self.toWP(c)])
snaps.append([v2,'center',self.toWP(c)])
if self.isEnabled("center"):
c = obj.Placement.Base
for edge in obj.Shape.Edges:
p1 = edge.Vertexes[0].Point
p2 = edge.Vertexes[-1].Point
v1 = p1.add((p2-p1).scale(.25,.25,.25))
v2 = p1.add((p2-p1).scale(.75,.75,.75))
snaps.append([v1,'center',self.toWP(c)])
snaps.append([v2,'center',self.toWP(c)])
return snaps

def snapToVertex(self,info,active=False):
Expand Down

0 comments on commit a6563fb

Please sign in to comment.