RuntimeError: Type Part::Compound cannot dynamically add properties

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
freecadlzh
Posts: 138
Joined: Fri Mar 06, 2020 12:52 pm

RuntimeError: Type Part::Compound cannot dynamically add properties

Post by freecadlzh »

I created 4 line objects by Draft, Need to make those 4 lines to one model, So Compounded them. So I created a compound object first.
Now I need add some custom property to the compound object, but the code can not run. The code is:

Code: Select all

        AConductorLine = FreeCAD.activeDocument().addObject("Part::Compound",FreeCAD.ConductorName)
        AConductorLine.addProperty("App::PropertyFloat", "lzhCustom")
        AConductorLine.lzhCustom = 0.67
The errors is :

Code: Select all

RuntimeError: Type Part::Compound cannot dynamically add properties
I tried some other way . And find out if I created a object by the code "App::FeaturePython","Part::FeaturePython",”Part::CustomFeaturePython”,"Mesh::FeaturePython" and so on. The object can add some custom property. But "Part::Compound" object can not!

I need using "Part::Compound" to create object is, the 4 line compounded can be rotated translated in the meantime. It looks like the 4 lines are one object. So I need using "Part::Compound" object to Compound the 4 line.

So I need find out a way to add some custom property to "Part::Compound" object.

Need suggestions. Thanks a lot.
Post Reply