Skip to content

Commit

Permalink
Draft: Center Snap can now also snap to center of faces
Browse files Browse the repository at this point in the history
  • Loading branch information
yorikvanhavre committed Jun 13, 2016
1 parent 092e8e1 commit 285f6ae
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/Mod/Draft/DraftSnap.py
Expand Up @@ -319,7 +319,11 @@ def cstr(point):
elif et == "Ellipse":
# extra ellipse options
snaps.extend(self.snapToCenter(edge))

elif "Face" in comp:
en = int(comp[4:])-1
if len(obj.Shape.Faces) > en:
face = obj.Shape.Faces[en]
snaps.extend(self.snapToFace(face))
elif "Vertex" in comp:
# directly snapped to a vertex
snaps.append(self.snapToVertex(self.snapInfo,active=True))
Expand Down Expand Up @@ -749,6 +753,15 @@ def snapToCenter(self,shape):
else:
snaps.append([c,'center',c])
return snaps

def snapToFace(self,shape):
"returns a face center snap location"
snaps = []
if self.isEnabled("center"):
pos = shape.CenterOfMass
c = self.toWP(pos)
snaps.append([pos,'center',c])
return snaps

def snapToIntersection(self,shape):
"returns a list of intersection snap locations"
Expand Down

0 comments on commit 285f6ae

Please sign in to comment.