Skip to content

Commit

Permalink
Draft: Allow to set the Working Plane from 3 selected vertices
Browse files Browse the repository at this point in the history
  • Loading branch information
yorikvanhavre committed May 20, 2017
1 parent c30c325 commit 8da4563
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Mod/Draft/DraftTools.py
Expand Up @@ -356,6 +356,17 @@ def Activated(self):
self.display(plane.axis)
self.finish()
return
elif len(sel.SubElementNames) == 3:
if ("Vertex" in sel.SubElementNames[0]) \
and ("Vertex" in sel.SubElementNames[1]) \
and ("Vertex" in sel.SubElementNames[2]):
plane.alignTo3Points(sel.SubObjects[0].Point,
sel.SubObjects[1].Point,
sel.SubObjects[2].Point,
self.offset)
self.display(plane.axis)
self.finish()
return
self.ui.selectPlaneUi()
msg(translate("draft", "Pick a face to define the drawing plane\n"))
if plane.alignToSelection(self.offset):
Expand Down
6 changes: 6 additions & 0 deletions src/Mod/Draft/WorkingPlane.py
Expand Up @@ -256,6 +256,12 @@ def alignToFace(self, shape, offset=0):
else:
return False

def alignTo3Points(self,p1,p2,p3,offset=0):
import Part
w = Part.makePolygon([p1,p2,p3,p1])
f = Part.Face(w)
return self.alignToFace(f,offset)

def alignToSelection(self, offset):
'''If selection uniquely defines a plane, align working plane to it. Return success (bool)'''
import FreeCADGui
Expand Down

0 comments on commit 8da4563

Please sign in to comment.