0
$\begingroup$

It seems that I have a couple plugins automatically creating custom properties with API Defined values on every object I make. Now that I'm starting to make drivers with custom properties, I want to get rid of these junk properties by just uninstalling the plugins that are creating them. Is there a way to trace back the origins for these automatically created custom properties?

enter image description here

$\endgroup$
2
$\begingroup$

Leave them be, create your own panel.

For 2 of the 3 examples shown its pretty obvious from which addons they come. Disabling the cycles render engine to have a clean custom properties panel is IMO not the way to go, going forward.

Recommend leaving the so called "junk properties" alone. Let the custom properties panel be populated by props defined in other addons, including your own. (The scene's custom props is surely the most over-populated). Accept that this panel fill with everyone's junk. Make your own panel that only displays what you want, where you want.

If a property is defined in an addon via

bpy.types.Object.foo = bpy.props.IntProperty(default=4)

The foo property is now available to all objects. Once set ob.foo = 3 its value is stored in blender via the custom property ob["foo"]. For a more detailed property setup like a collection, it displays in UI as "API defined".

Unregistering an addon may or may not remove the storage. Eg ob.foo is defined in an addon, and on unregister is no longer available, but ob["foo"] still persists, where set, and available when the addon registered next time.

As well as storing the value it also stores the properties of the property, eg min and max. This can be manipulated via the objects ob["_RNA_UI"] custom property, with the key "foo" ob["_RNA_UI"]["foo"].

Hence not defining with bpy.props as above can create, set, and add UI properties with:

>>> ob["foo"] = 3
>>> if not ob['_RNA_UI']:
...     ob['_RNA_UI'] = {}
...     
>>> ob['_RNA_UI']["foo"] = {"description" : "FooBar", "driver_prop" : True, "max" : 10}
>>> "driver_prop" in ob["_RNA_UI"]["foo"].keys()
True

Now we have a custom property named "foo" description (tooltip) "Foobar" that has a maximum value of 10 and a flag indicated it is being used to drive something. All of the rna props, eg max, need to be of type int, float, bool or str. The "driver_prop" key shows how these can be other than the arguments of the bpy.props property.

For more info see ./2.80/scripts/modules/rna_prop_ui.py on how to add your own "Add Custom Prop" button to your addon panel.

To remove all custom props from an object (for answer sake, not recommended)

for k in ob.keys():
    del ob[k]
$\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.