From f43fcd1fb5e1d190fe32acbedeee17a658356938 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Thu, 18 Jul 2013 16:26:00 -0300 Subject: [PATCH] Arch: Wall and Struct tools now set the working plane before drawing --- src/Mod/Arch/ArchStructure.py | 2 ++ src/Mod/Arch/ArchWall.py | 2 ++ src/Mod/Draft/DraftTools.py | 7 +------ src/Mod/Draft/WorkingPlane.py | 14 ++++++++++++-- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/Mod/Arch/ArchStructure.py b/src/Mod/Arch/ArchStructure.py index 379730903..73b70ef18 100644 --- a/src/Mod/Arch/ArchStructure.py +++ b/src/Mod/Arch/ArchStructure.py @@ -94,6 +94,8 @@ class _CommandStructure: FreeCAD.ActiveDocument.recompute() else: # interactive mode + if hasattr(FreeCAD,"DraftWorkingPlane"): + FreeCAD.DraftWorkingPlane.setup() import DraftTrackers self.points = [] self.tracker = DraftTrackers.boxTracker() diff --git a/src/Mod/Arch/ArchWall.py b/src/Mod/Arch/ArchWall.py index 5f0ca5cb0..6b60020bf 100644 --- a/src/Mod/Arch/ArchWall.py +++ b/src/Mod/Arch/ArchWall.py @@ -157,6 +157,8 @@ class _CommandWall: import DraftTrackers self.points = [] self.tracker = DraftTrackers.boxTracker() + if hasattr(FreeCAD,"DraftWorkingPlane"): + FreeCAD.DraftWorkingPlane.setup() FreeCADGui.Snapper.getPoint(callback=self.getPoint,extradlg=self.taskbox()) def getPoint(self,point=None,obj=None): diff --git a/src/Mod/Draft/DraftTools.py b/src/Mod/Draft/DraftTools.py index 25b63953f..18854b4f0 100644 --- a/src/Mod/Draft/DraftTools.py +++ b/src/Mod/Draft/DraftTools.py @@ -232,12 +232,7 @@ class DraftTool: self.ui.sourceCmd = self self.ui.setTitle(name) self.ui.show() - try: - rot = self.view.getCameraNode().getField("orientation").getValue() - upv = Vector(rot.multVec(coin.SbVec3f(0,1,0)).getValue()) - plane.setup(DraftVecUtils.neg(self.view.getViewDirection()), Vector(0,0,0), upv) - except: - pass + plane.setup() self.node = [] self.pos = [] self.constrain = None diff --git a/src/Mod/Draft/WorkingPlane.py b/src/Mod/Draft/WorkingPlane.py index a0057df5e..8ef841457 100644 --- a/src/Mod/Draft/WorkingPlane.py +++ b/src/Mod/Draft/WorkingPlane.py @@ -187,10 +187,20 @@ class plane: # len(sex) > 2, look for point and line, three points, etc. return False - def setup(self, direction, point, upvec=None): + def setup(self, direction=None, point=None, upvec=None): '''If working plane is undefined, define it!''' if self.weak: - self.alignToPointAndAxis(point, direction, 0, upvec) + if direction and point: + self.alignToPointAndAxis(point, direction, 0, upvec) + else: + try: + from pivy import coin + rot = FreeCADGui.ActiveDocument.ActiveView.getCameraNode().getField("orientation").getValue() + upvec = Vector(rot.multVec(coin.SbVec3f(0,1,0)).getValue()) + vdir = FreeCADGui.ActiveDocument.ActiveView.getViewDirection() + self.alignToPointAndAxis(Vector(0,0,0), DraftVecUtils.neg(vdir), upvec) + except: + print "Draft: Unable to align the working plane to the current view" self.weak = True def reset(self):