From fd79e3e3a992fd7ce5a75a1a51db42c151ebbc64 Mon Sep 17 00:00:00 2001 From: carlopav Date: Sat, 27 Jun 2020 23:24:09 +0200 Subject: [PATCH] Draft: possibility to set the working plane to an App::Part placement --- src/Mod/Draft/WorkingPlane.py | 2 +- src/Mod/Draft/draftguitools/gui_selectplane.py | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Mod/Draft/WorkingPlane.py b/src/Mod/Draft/WorkingPlane.py index 7201433eaf..b09e061f98 100644 --- a/src/Mod/Draft/WorkingPlane.py +++ b/src/Mod/Draft/WorkingPlane.py @@ -694,7 +694,7 @@ class Plane: if self.weak or force: if direction and point: self.alignToPointAndAxis(point, direction, 0, upvec) - else: + elif FreeCAD.GuiUp: try: import FreeCADGui from pivy import coin diff --git a/src/Mod/Draft/draftguitools/gui_selectplane.py b/src/Mod/Draft/draftguitools/gui_selectplane.py index 60834847cd..d569f79709 100644 --- a/src/Mod/Draft/draftguitools/gui_selectplane.py +++ b/src/Mod/Draft/draftguitools/gui_selectplane.py @@ -186,7 +186,14 @@ class Draft_SelectPlane: sel = FreeCADGui.Selection.getSelectionEx() if len(sel) == 1: sel = sel[0] - if Draft.getType(sel.Object) == "Axis": + if hasattr(sel.Object, 'TypeId') and sel.Object.TypeId == 'App::Part': + FreeCAD.DraftWorkingPlane.setFromPlacement(sel.Object.getGlobalPlacement(), rebase=True) + FreeCAD.DraftWorkingPlane.weak = False + self.display(FreeCAD.DraftWorkingPlane.axis) + self.wpButton.setText(sel.Object.Label) + self.wpButton.setToolTip(translate("draft", "Current working plane")+": " + self.wpButton.text()) + return True + elif Draft.getType(sel.Object) == "Axis": FreeCAD.DraftWorkingPlane.alignToEdges(sel.Object.Shape.Edges) self.display(FreeCAD.DraftWorkingPlane.axis) return True @@ -274,6 +281,7 @@ class Draft_SelectPlane: self.display(FreeCAD.DraftWorkingPlane.axis) return True elif sel: + # try to setup the working plane for 3 vertexes subs = [] import Part for s in sel: