0001078: Draft now snaps to center of polygons and cylinders
This commit is contained in:
parent
f05be462bc
commit
33faa40101
|
@ -301,6 +301,8 @@ def findIntersection(edge1,edge2,infinite1=False,infinite2=False,ex1=False,ex2=F
|
||||||
if dirVec.dot(arc.Curve.Axis) != 0 :
|
if dirVec.dot(arc.Curve.Axis) != 0 :
|
||||||
toPlane = Vector(arc.Curve.Axis) ; toPlane.normalize()
|
toPlane = Vector(arc.Curve.Axis) ; toPlane.normalize()
|
||||||
d = pt1.dot(toPlane)
|
d = pt1.dot(toPlane)
|
||||||
|
if not d:
|
||||||
|
return []
|
||||||
dToPlane = center.sub(pt1).dot(toPlane)
|
dToPlane = center.sub(pt1).dot(toPlane)
|
||||||
toPlane = Vector(pt1)
|
toPlane = Vector(pt1)
|
||||||
toPlane.scale(dToPlane/d,dToPlane/d,dToPlane/d)
|
toPlane.scale(dToPlane/d,dToPlane/d,dToPlane/d)
|
||||||
|
|
|
@ -269,6 +269,9 @@ class Snapper:
|
||||||
snaps.append([b,'endpoint',b])
|
snaps.append([b,'endpoint',b])
|
||||||
|
|
||||||
elif obj.isDerivedFrom("Part::Feature"):
|
elif obj.isDerivedFrom("Part::Feature"):
|
||||||
|
if Draft.getType(obj) == "Polygon":
|
||||||
|
snaps.extend(self.snapToPolygon(obj))
|
||||||
|
|
||||||
if (not self.maxEdges) or (len(obj.Edges) <= self.maxEdges):
|
if (not self.maxEdges) or (len(obj.Edges) <= self.maxEdges):
|
||||||
if "Edge" in comp:
|
if "Edge" in comp:
|
||||||
# we are snapping to an edge
|
# we are snapping to an edge
|
||||||
|
@ -650,6 +653,19 @@ class Snapper:
|
||||||
for p in pt:
|
for p in pt:
|
||||||
snaps.append([p,'intersection',p])
|
snaps.append([p,'intersection',p])
|
||||||
return snaps
|
return snaps
|
||||||
|
|
||||||
|
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',c])
|
||||||
|
snaps.append([v2,'center',c])
|
||||||
|
return snaps
|
||||||
|
|
||||||
def snapToVertex(self,info,active=False):
|
def snapToVertex(self,info,active=False):
|
||||||
p = Vector(info['x'],info['y'],info['z'])
|
p = Vector(info['x'],info['y'],info['z'])
|
||||||
|
|
Loading…
Reference in New Issue
Block a user