2
$\begingroup$

I have created a PropertyGroup as follows:

# Define property groups...
class ObjectPropGroup(bpy.types.PropertyGroup):
    edge_display = BoolProperty(default=False, name="Edge Display")

#initialize custom property groups...
bpy.types.Object.ObjectProp   = PointerProperty(type = ObjectPropGroup)

When i now create a new object obj and then look into the custom properties list, ObjectProp is not listed. But as soon as i add a property to the group:

obj.ObjectProp.edge_display=True

now the ObjectProp appears in the list of custom properties of the object. This is all good so far. But now i run into a small problem when i want to cleanup the object and remove all elements from ObjectProp. So what i do for now is:

for key in obj.ObjectProp.keys(): del bpy.context.object.ObjectProp[key]

This works as expected and deletes all data. However the ObjectProp itself keeps in the list of custom properties with an empty data set {} Is there a way reset obj into its initial state so that ObjectProp is no longer shown in the custom properties list? I tried the easy way but that failed:

del obj.ObjectProp
Traceback (most recent call last):
  File "<blender_console>", line 1, in <module>
AttributeError: bpy_struct: attribute "ObjectProp" from "Object" is read-only

Is there a solution?

$\endgroup$
0
2
$\begingroup$

The answer is so stupid simple:

del obj['ObjectProp']

However i hope this question is still helpful for some others.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.