Draft: Allow to set the Working Plane from 3 selected vertices

This commit is contained in:
Yorik van Havre
2017-05-20 00:53:11 -03:00
parent 3d8eba966b
commit 9fe7b89ff0
2 changed files with 17 additions and 0 deletions

View File

@@ -356,6 +356,17 @@ class SelectPlane(DraftTool):
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):

View File

@@ -256,6 +256,12 @@ class plane:
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