From 2175eb0939aa3061c7a69d6e1ff2c5cfaad4eba5 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Thu, 9 Apr 2020 16:59:01 +0200 Subject: [PATCH] Draft: Added convenience methods to the Draft Working Plane to set top, front and side positions --- src/Mod/Draft/WorkingPlane.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/Mod/Draft/WorkingPlane.py b/src/Mod/Draft/WorkingPlane.py index 7efe0f4c81..7201433eaf 100644 --- a/src/Mod/Draft/WorkingPlane.py +++ b/src/Mod/Draft/WorkingPlane.py @@ -726,6 +726,39 @@ class Plane: self.doc = None self.weak = True + def setTop(self): + """sets the WP to top position and updates the GUI""" + self.alignToPointAndAxis(FreeCAD.Vector(0.0, 0.0, 0.0), FreeCAD.Vector(0, 0, 1), 0.0) + if FreeCAD.GuiUp: + import FreeCADGui + from draftutils.translate import translate + if hasattr(FreeCADGui,"Snapper"): + FreeCADGui.Snapper.setGrid() + if hasattr(FreeCADGui,"draftToolBar"): + FreeCADGui.draftToolBar.wplabel.setText(translate("draft", "Top")) + + def setFront(self): + """sets the WP to front position and updates the GUI""" + self.alignToPointAndAxis(FreeCAD.Vector(0.0, 0.0, 0.0), FreeCAD.Vector(0, 1, 0), 0.0) + if FreeCAD.GuiUp: + import FreeCADGui + from draftutils.translate import translate + if hasattr(FreeCADGui,"Snapper"): + FreeCADGui.Snapper.setGrid() + if hasattr(FreeCADGui,"draftToolBar"): + FreeCADGui.draftToolBar.wplabel.setText(translate("draft", "Front")) + + def setSide(self): + """sets the WP to top position and updates the GUI""" + self.alignToPointAndAxis(FreeCAD.Vector(0.0, 0.0, 0.0), FreeCAD.Vector(-1, 0, 0), 0.0) + if FreeCAD.GuiUp: + import FreeCADGui + from draftutils.translate import translate + if hasattr(FreeCADGui,"Snapper"): + FreeCADGui.Snapper.setGrid() + if hasattr(FreeCADGui,"draftToolBar"): + FreeCADGui.draftToolBar.wplabel.setText(translate("draft", "Side")) + def getRotation(self): """Return a placement describing the plane orientation only.