From ffbbcd897f620510f027c875bee0cc2645cbbb4f Mon Sep 17 00:00:00 2001 From: "Zheng, Lei" Date: Sat, 12 Sep 2020 02:42:57 +0000 Subject: [PATCH] Fix adding object to PartDesign::Body --- freecad/gears/commands.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/freecad/gears/commands.py b/freecad/gears/commands.py index 6e43e41..50bcb3e 100644 --- a/freecad/gears/commands.py +++ b/freecad/gears/commands.py @@ -49,20 +49,25 @@ class BaseCommand(object): @classmethod def create(cls): - obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", cls.NAME) - cls.GEAR_FUNCTION(obj) 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") + if body: + obj = FreeCAD.ActiveDocument.addObject("PartDesign::FeaturePython", cls.NAME) + + ViewProviderGear(obj.ViewObject) + cls.GEAR_FUNCTION(obj) + if body: body.Group += [obj] elif part: part.Group += [obj] + else: + obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", cls.NAME) + cls.GEAR_FUNCTION(obj) return obj def GetResources(self):