From b74c96dcc4947dce27032e9dceb9d3210181df37 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Tue, 29 Jul 2014 22:20:06 -0300 Subject: [PATCH] Draft + Arch: fixes when working without the GUI --- src/Mod/Arch/ArchComponent.py | 2 -- src/Mod/Arch/ArchStructure.py | 3 ++- src/Mod/Draft/Draft.py | 21 ++++++++++++--------- src/Mod/Draft/WorkingPlane.py | 6 ++++-- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/Mod/Arch/ArchComponent.py b/src/Mod/Arch/ArchComponent.py index fa21840fb5..9f80561119 100644 --- a/src/Mod/Arch/ArchComponent.py +++ b/src/Mod/Arch/ArchComponent.py @@ -352,8 +352,6 @@ class Component: def getProfiles(self,obj,noplacement=False): "Returns the base profile(s) of this component, if applicable" - if not obj.Shape: return [] - if obj.Shape.isNull(): return [] wires = [] n,l,w,h = self.getDefaultValues(obj) if obj.Base: diff --git a/src/Mod/Arch/ArchStructure.py b/src/Mod/Arch/ArchStructure.py index 19f6912896..94d364a749 100644 --- a/src/Mod/Arch/ArchStructure.py +++ b/src/Mod/Arch/ArchStructure.py @@ -300,7 +300,8 @@ def makeStructure(baseobj=None,length=None,width=None,height=None,name=translate obj.ViewObject.ShapeColor = ArchCommands.getDefaultColor("Structure") if baseobj: obj.Base = baseobj - obj.Base.ViewObject.hide() + if FreeCAD.GuiUp: + obj.Base.ViewObject.hide() if width: obj.Width = width else: diff --git a/src/Mod/Draft/Draft.py b/src/Mod/Draft/Draft.py index a06f8874e1..ea80b8af17 100644 --- a/src/Mod/Draft/Draft.py +++ b/src/Mod/Draft/Draft.py @@ -682,7 +682,7 @@ def makeDimension(p1,p2,p3=None,p4=None): if hasattr(FreeCAD,"DraftWorkingPlane"): normal = FreeCAD.DraftWorkingPlane.axis else: - normal = App.Vector(0,0,1) + normal = FreeCAD.Vector(0,0,1) if gui: # invert the normal if we are viewing it from the back vnorm = get3DView().getViewDirection() @@ -890,14 +890,17 @@ def makeText(stringslist,point=Vector(0,0,0),screen=False): obj=FreeCAD.ActiveDocument.addObject("App::Annotation","Text") obj.LabelText=textbuffer obj.Position=point - if not screen: obj.ViewObject.DisplayMode="World" - h = getParam("textheight",0.20) - if screen: h = h*10 - obj.ViewObject.FontSize = h - obj.ViewObject.FontName = getParam("textfont","") - obj.ViewObject.LineSpacing = 0.6 - formatObject(obj) - select(obj) + if FreeCAD.GuiUp: + if not screen: + obj.ViewObject.DisplayMode="World" + h = getParam("textheight",0.20) + if screen: + h = h*10 + obj.ViewObject.FontSize = h + obj.ViewObject.FontName = getParam("textfont","") + obj.ViewObject.LineSpacing = 0.6 + formatObject(obj) + select(obj) return obj def makeCopy(obj,force=None,reparent=False): diff --git a/src/Mod/Draft/WorkingPlane.py b/src/Mod/Draft/WorkingPlane.py index 69207bd067..6171f510a7 100644 --- a/src/Mod/Draft/WorkingPlane.py +++ b/src/Mod/Draft/WorkingPlane.py @@ -22,7 +22,7 @@ #*************************************************************************** -import FreeCAD, FreeCADGui, math, DraftVecUtils +import FreeCAD, math, DraftVecUtils from FreeCAD import Vector __title__="FreeCAD Working Plane utility" @@ -232,6 +232,7 @@ class plane: def alignToSelection(self, offset): '''If selection uniquely defines a plane, align working plane to it. Return success (bool)''' + import FreeCADGui sex = FreeCADGui.Selection.getSelectionEx(FreeCAD.ActiveDocument.Name) if len(sex) == 0: return False @@ -252,13 +253,14 @@ class plane: self.alignToPointAndAxis(point, direction, 0, upvec) else: try: + import FreeCADGui 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), vdir.negative(), 0, upvec) except: - print "Draft: Unable to align the working plane to the current view" + pass self.weak = True def reset(self):