Draft + Arch: fixes when working without the GUI
This commit is contained in:
parent
580c541005
commit
b74c96dcc4
|
@ -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:
|
||||||
|
|
|
@ -300,6 +300,7 @@ 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
|
||||||
|
if FreeCAD.GuiUp:
|
||||||
obj.Base.ViewObject.hide()
|
obj.Base.ViewObject.hide()
|
||||||
if width:
|
if width:
|
||||||
obj.Width = width
|
obj.Width = width
|
||||||
|
|
|
@ -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,9 +890,12 @@ 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:
|
||||||
|
if not screen:
|
||||||
|
obj.ViewObject.DisplayMode="World"
|
||||||
h = getParam("textheight",0.20)
|
h = getParam("textheight",0.20)
|
||||||
if screen: h = h*10
|
if screen:
|
||||||
|
h = h*10
|
||||||
obj.ViewObject.FontSize = h
|
obj.ViewObject.FontSize = h
|
||||||
obj.ViewObject.FontName = getParam("textfont","")
|
obj.ViewObject.FontName = getParam("textfont","")
|
||||||
obj.ViewObject.LineSpacing = 0.6
|
obj.ViewObject.LineSpacing = 0.6
|
||||||
|
|
|
@ -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):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user