Draft + Arch: fixes when working without the GUI

This commit is contained in:
Yorik van Havre 2014-07-29 22:20:06 -03:00
parent 580c541005
commit b74c96dcc4
4 changed files with 18 additions and 14 deletions

View File

@ -352,8 +352,6 @@ class Component:
def getProfiles(self,obj,noplacement=False): def getProfiles(self,obj,noplacement=False):
"Returns the base profile(s) of this component, if applicable" "Returns the base profile(s) of this component, if applicable"
if not obj.Shape: return []
if obj.Shape.isNull(): return []
wires = [] wires = []
n,l,w,h = self.getDefaultValues(obj) n,l,w,h = self.getDefaultValues(obj)
if obj.Base: if obj.Base:

View File

@ -300,7 +300,8 @@ def makeStructure(baseobj=None,length=None,width=None,height=None,name=translate
obj.ViewObject.ShapeColor = ArchCommands.getDefaultColor("Structure") obj.ViewObject.ShapeColor = ArchCommands.getDefaultColor("Structure")
if baseobj: if baseobj:
obj.Base = baseobj obj.Base = baseobj
obj.Base.ViewObject.hide() if FreeCAD.GuiUp:
obj.Base.ViewObject.hide()
if width: if width:
obj.Width = width obj.Width = width
else: else:

View File

@ -682,7 +682,7 @@ def makeDimension(p1,p2,p3=None,p4=None):
if hasattr(FreeCAD,"DraftWorkingPlane"): if hasattr(FreeCAD,"DraftWorkingPlane"):
normal = FreeCAD.DraftWorkingPlane.axis normal = FreeCAD.DraftWorkingPlane.axis
else: else:
normal = App.Vector(0,0,1) normal = FreeCAD.Vector(0,0,1)
if gui: if gui:
# invert the normal if we are viewing it from the back # invert the normal if we are viewing it from the back
vnorm = get3DView().getViewDirection() 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=FreeCAD.ActiveDocument.addObject("App::Annotation","Text")
obj.LabelText=textbuffer obj.LabelText=textbuffer
obj.Position=point obj.Position=point
if not screen: obj.ViewObject.DisplayMode="World" if FreeCAD.GuiUp:
h = getParam("textheight",0.20) if not screen:
if screen: h = h*10 obj.ViewObject.DisplayMode="World"
obj.ViewObject.FontSize = h h = getParam("textheight",0.20)
obj.ViewObject.FontName = getParam("textfont","") if screen:
obj.ViewObject.LineSpacing = 0.6 h = h*10
formatObject(obj) obj.ViewObject.FontSize = h
select(obj) obj.ViewObject.FontName = getParam("textfont","")
obj.ViewObject.LineSpacing = 0.6
formatObject(obj)
select(obj)
return obj return obj
def makeCopy(obj,force=None,reparent=False): def makeCopy(obj,force=None,reparent=False):

View File

@ -22,7 +22,7 @@
#*************************************************************************** #***************************************************************************
import FreeCAD, FreeCADGui, math, DraftVecUtils import FreeCAD, math, DraftVecUtils
from FreeCAD import Vector from FreeCAD import Vector
__title__="FreeCAD Working Plane utility" __title__="FreeCAD Working Plane utility"
@ -232,6 +232,7 @@ class plane:
def alignToSelection(self, offset): def alignToSelection(self, offset):
'''If selection uniquely defines a plane, align working plane to it. Return success (bool)''' '''If selection uniquely defines a plane, align working plane to it. Return success (bool)'''
import FreeCADGui
sex = FreeCADGui.Selection.getSelectionEx(FreeCAD.ActiveDocument.Name) sex = FreeCADGui.Selection.getSelectionEx(FreeCAD.ActiveDocument.Name)
if len(sex) == 0: if len(sex) == 0:
return False return False
@ -252,13 +253,14 @@ class plane:
self.alignToPointAndAxis(point, direction, 0, upvec) self.alignToPointAndAxis(point, direction, 0, upvec)
else: else:
try: try:
import FreeCADGui
from pivy import coin from pivy import coin
rot = FreeCADGui.ActiveDocument.ActiveView.getCameraNode().getField("orientation").getValue() rot = FreeCADGui.ActiveDocument.ActiveView.getCameraNode().getField("orientation").getValue()
upvec = Vector(rot.multVec(coin.SbVec3f(0,1,0)).getValue()) upvec = Vector(rot.multVec(coin.SbVec3f(0,1,0)).getValue())
vdir = FreeCADGui.ActiveDocument.ActiveView.getViewDirection() vdir = FreeCADGui.ActiveDocument.ActiveView.getViewDirection()
self.alignToPointAndAxis(Vector(0,0,0), vdir.negative(), 0, upvec) self.alignToPointAndAxis(Vector(0,0,0), vdir.negative(), 0, upvec)
except: except:
print "Draft: Unable to align the working plane to the current view" pass
self.weak = True self.weak = True
def reset(self): def reset(self):