Skip to content

Commit

Permalink
Isolate FreeCADGui dependency
Browse files Browse the repository at this point in the history
Thanks @mlampert and @sliptonic for assisting in tracking down the error via unit test analysis.
FreeCADGui usage has to be behind an 'if FreeCAD.GuiUp:` test
  • Loading branch information
Russ4262 committed Jun 13, 2019
1 parent 4b104c4 commit 236e1da
Showing 1 changed file with 25 additions and 18 deletions.
43 changes: 25 additions & 18 deletions src/Mod/Path/PathScripts/PathAreaOp.py
Expand Up @@ -54,7 +54,7 @@
__contributors__ = "mlampert [FreeCAD], russ4262 (Russell Johnson)"
__createdDate__ = "2017"
__scriptVersion__ = "2g testing"
__lastModified__ = "2019-06-12 23:29 CST"
__lastModified__ = "2019-06-13 15:37 CST"

if False:
PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule())
Expand Down Expand Up @@ -751,7 +751,8 @@ def visualAxis(self):
yAx = 'yAxCyl'
zAx = 'zAxCyl'
FreeCAD.ActiveDocument.addObject("App::DocumentObjectGroup","visualAxis")
FreeCADGui.ActiveDocument.getObject('visualAxis').Visibility = False
if FreeCAD.GuiUp:
FreeCADGui.ActiveDocument.getObject('visualAxis').Visibility = False
vaGrp = FreeCAD.ActiveDocument.getObject("visualAxis")

FreeCAD.ActiveDocument.addObject("Part::Cylinder", xAx)
Expand All @@ -761,10 +762,11 @@ def visualAxis(self):
cyl.Height = 0.01
cyl.Placement = FreeCAD.Placement(FreeCAD.Vector(0,0,0),FreeCAD.Rotation(FreeCAD.Vector(0,1,0),90))
cyl.purgeTouched()
cylGui = FreeCADGui.ActiveDocument.getObject(xAx)
cylGui.ShapeColor = (0.667,0.000,0.000)
cylGui.Transparency = 85
cylGui.Visibility = False
if FreeCAD.GuiUp:
cylGui = FreeCADGui.ActiveDocument.getObject(xAx)
cylGui.ShapeColor = (0.667,0.000,0.000)
cylGui.Transparency = 85
cylGui.Visibility = False
vaGrp.addObject(cyl)

FreeCAD.ActiveDocument.addObject("Part::Cylinder", yAx)
Expand All @@ -774,10 +776,11 @@ def visualAxis(self):
cyl.Height = 0.01
cyl.Placement = FreeCAD.Placement(FreeCAD.Vector(0,0,0),FreeCAD.Rotation(FreeCAD.Vector(1,0,0),90))
cyl.purgeTouched()
cylGui = FreeCADGui.ActiveDocument.getObject(yAx)
cylGui.ShapeColor = (0.000,0.667,0.000)
cylGui.Transparency = 85
cylGui.Visibility = False
if FreeCAD.GuiUp:
cylGui = FreeCADGui.ActiveDocument.getObject(yAx)
cylGui.ShapeColor = (0.000,0.667,0.000)
cylGui.Transparency = 85
cylGui.Visibility = False
vaGrp.addObject(cyl)

if False:
Expand All @@ -788,10 +791,11 @@ def visualAxis(self):
cyl.Height = 0.01
# cyl.Placement = FreeCAD.Placement(FreeCAD.Vector(0,0,0),FreeCAD.Rotation(FreeCAD.Vector(1,0,0),90))
cyl.purgeTouched()
cylGui = FreeCADGui.ActiveDocument.getObject(zAx)
cylGui.ShapeColor = (0.000,0.000,0.498)
cylGui.Transparency = 85
cylGui.Visibility = False
if FreeCAD.GuiUp:
cylGui = FreeCADGui.ActiveDocument.getObject(zAx)
cylGui.ShapeColor = (0.000,0.000,0.498)
cylGui.Transparency = 85
cylGui.Visibility = False
vaGrp.addObject(cyl)

def useTempJobClones(self, cloneName):
Expand All @@ -810,11 +814,13 @@ def useTempJobClones(self, cloneName):
FreeCAD.ActiveDocument.removeObject('rotJobClones')
else:
FreeCAD.ActiveDocument.addObject("App::DocumentObjectGroup","rotJobClones")
FreeCADGui.ActiveDocument.getObject('rotJobClones').Visibility = False
if FreeCAD.GuiUp:
FreeCADGui.ActiveDocument.getObject('rotJobClones').Visibility = False

if cloneName != 'Start' and cloneName != 'Delete':
FreeCAD.ActiveDocument.getObject('rotJobClones').addObject(FreeCAD.ActiveDocument.getObject(cloneName))
FreeCADGui.ActiveDocument.getObject(cloneName).Visibility = False
if FreeCAD.GuiUp:
FreeCADGui.ActiveDocument.getObject(cloneName).Visibility = False

def cloneBaseAndStock(self, obj, base, angle, axis, subCount):
'''cloneBaseAndStock(obj, base, angle, axis, subCount)
Expand All @@ -837,8 +843,9 @@ def cloneBaseAndStock(self, obj, base, angle, axis, subCount):
FreeCAD.ActiveDocument.removeObject(stckClnNm)
FreeCAD.ActiveDocument.addObject('Part::Feature', clnNm).Shape = base.Shape
FreeCAD.ActiveDocument.addObject('Part::Feature', stckClnNm).Shape = PathUtils.findParentJob(obj).Stock.Shape
FreeCADGui.ActiveDocument.getObject(stckClnNm).Transparency=90
FreeCADGui.ActiveDocument.getObject(clnNm).ShapeColor = (1.000,0.667,0.000)
if FreeCAD.GuiUp:
FreeCADGui.ActiveDocument.getObject(stckClnNm).Transparency=90
FreeCADGui.ActiveDocument.getObject(clnNm).ShapeColor = (1.000,0.667,0.000)
self.useTempJobClones(clnNm)
self.useTempJobClones(stckClnNm)
clnBase = FreeCAD.ActiveDocument.getObject(clnNm)
Expand Down

0 comments on commit 236e1da

Please sign in to comment.