remove gui commands if no gui is available

This commit is contained in:
looooo
2020-08-30 04:49:12 +02:00
parent 4d16094b25
commit 19a826cf1b

View File

@@ -51,17 +51,18 @@ class BaseCommand(object):
def create(cls):
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", cls.NAME)
cls.GEAR_FUNCTION(obj)
ViewProviderGear(obj.ViewObject)
if FreeCAD.GuiUp:
ViewProviderGear(obj.ViewObject)
# borrowed from threaded profiles
# puts the gear into an active container
body = Gui.ActiveDocument.ActiveView.getActiveObject("pdbody")
part = Gui.ActiveDocument.ActiveView.getActiveObject("part")
# borrowed from threaded profiles
# puts the gear into an active container
body = Gui.ActiveDocument.ActiveView.getActiveObject("pdbody")
part = Gui.ActiveDocument.ActiveView.getActiveObject("part")
if body:
body.Group += [obj]
elif part:
part.Group += [obj]
if body:
body.Group += [obj]
elif part:
part.Group += [obj]
return obj
def GetResources(self):