From 9fe7b89ff04ffc6f6b342e142bc71e362a16dd35 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Sat, 20 May 2017 00:53:11 -0300 Subject: [PATCH] Draft: Allow to set the Working Plane from 3 selected vertices --- src/Mod/Draft/DraftTools.py | 11 +++++++++++ src/Mod/Draft/WorkingPlane.py | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/src/Mod/Draft/DraftTools.py b/src/Mod/Draft/DraftTools.py index f6d8313802..1076351309 100644 --- a/src/Mod/Draft/DraftTools.py +++ b/src/Mod/Draft/DraftTools.py @@ -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): diff --git a/src/Mod/Draft/WorkingPlane.py b/src/Mod/Draft/WorkingPlane.py index 1808599088..24d6dc0cf2 100644 --- a/src/Mod/Draft/WorkingPlane.py +++ b/src/Mod/Draft/WorkingPlane.py @@ -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