Draft: Center Snap can now also snap to center of faces

This commit is contained in:
Yorik van Havre 2016-06-13 13:46:51 -03:00
parent 092e8e10c1
commit 285f6aea9d

View File

@ -319,7 +319,11 @@ class Snapper:
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))
@ -749,6 +753,15 @@ class Snapper:
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"