Loading problems

Need help, or want to share a macro? Post here!
Post Reply
User avatar
iplayfast
Posts: 204
Joined: Sat Sep 07, 2019 6:55 am

Loading problems

Post by iplayfast »

My initialization code works fine when I create the object, but when I reload from disk, the gear_box_obj is decoupled from the GearBoxParameters.

This is the code that I initialize with.

Code: Select all

        doc = App.ActiveDocument
        body = doc.addObject('PartDesign::Body', 'gear_box')        
        gear_box_obj = doc.addObject("Part::FeaturePython", "GearBoxParameters")
        gear_box = CycloidalGearBox(gear_box_obj)        
CycloidalGearBox is a class that adds attributes to gear_box_obj and adds the object to itself for reference.

Code: Select all

class CycloidalGearBox():
    def __init__(self, obj):     
        ...
        obj.addProperty("App::PropertyLength", "clearance", "CycloidGearBox", QT_TRANSLATE_NOOP(
            "App::Property", "clearance between parts")).clearance = H["clearance"]
        self.Type = 'CycloidalGearBox'
        self.Object = obj
        self.doc = App.ActiveDocument
        obj.Proxy = self
        attrs = vars(self)
I'm sure that I'm not doing this properly.
Thanks in advance for helping.
Post Reply