Extending MeshObject class #968
-
I'm trying to write a class that extends MeshObject so I can tack on a few properties of my own for a project. While doing this, I noticed setattr raises a RuntimeError when anything other than blender_obj is set. I know I can just override it in my own class, but I would like to know what the reason is for this before I go break something on accident. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hey @njsymanz, the set_attr just makes sure that no other attributes are set, as they would not be persistent. MeshObject is just as wrapper around blender objects, so the idea is that all state is stored inside the blender object, e.g. using custom properties. |
Beta Was this translation helpful? Give feedback.
Hey @njsymanz,
the set_attr just makes sure that no other attributes are set, as they would not be persistent. MeshObject is just as wrapper around blender objects, so the idea is that all state is stored inside the blender object, e.g. using custom properties.
You can of course remove the set_attr in your custom class and add custom attributes, you just need to make sure that you keep the object instances in your script after loading and not use e.g.
bproc.object.get_all_mesh_objects()
.