4
$\begingroup$

It's clear how to set and retrieve custom properties from an object with python, but how do you get all the custom properties that were set to an object ?

$\endgroup$

1 Answer 1

10
$\begingroup$

UI defined custom properties.

If you mean those defined by the UI

enter image description here Example, two custom properties on default object

Iterate over custom properties without searching?

Their names via keys

>>> C.object.keys()
['prop', '_RNA_UI', 'prop1']

or via items to get key, value pairs

>>> for k, v in C.object.items():
...     print(f'ob["{k}"] = {repr(v)}')
...     
ob["prop"] = 1.0
ob["_RNA_UI"] = <bpy id prop: owner="OBCube", name="_RNA_UI", address=0x7fa661ad48c8>
ob["prop1"] = 1.0

The _RNA_UI member holds all the info re min, max, description for layout, when not defined with a bpy.props. (If defined via bpy.props and non default the data is saved as a custom prop of same name)

Finding the source for "API Defined" custom properties

When should custom-properties be used instead of 'bpy.props'?

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .