Snap Draft geometry to points in Points Features

This commit is contained in:
Sebastian Hoogen 2012-04-27 18:24:17 +02:00
parent 0d867c983f
commit 74305424b1
2 changed files with 11 additions and 2 deletions

View File

@ -167,6 +167,8 @@ def getType(obj):
return "Annotation"
if obj.isDerivedFrom("Mesh::Feature"):
return "Mesh"
if obj.isDerivedFrom("Points::Feature"):
return "Points"
if (obj.Type == "App::DocumentObjectGroup"):
return "Group"
return "Unknown"

View File

@ -271,6 +271,9 @@ class Snapper:
elif Draft.getType(obj) == "Mesh":
# for meshes we only snap to vertices
snaps.extend(self.snapToEndpoints(obj.Mesh))
elif Draft.getType(obj) == "Points":
# for points we only snap to points
snaps.extend(self.snapToEndpoints(obj.Points))
# updating last objects list
if not self.lastObj[1]:
@ -428,8 +431,12 @@ class Snapper:
elif hasattr(shape,"Point"):
snaps.append([shape.Point,'endpoint',shape.Point])
elif hasattr(shape,"Points"):
for v in shape.Points:
snaps.append([v.Vector,'endpoint',v.Vector])
if len(shape.Points) and hasattr(shape.Points[0],"Vector"):
for v in shape.Points:
snaps.append([v.Vector,'endpoint',v.Vector])
else:
for v in shape.Points:
snaps.append([v,'endpoint',v])
return snaps
def snapToMidpoint(self,shape):