2
$\begingroup$

I'd like to access user-defined custom properties (those that can be created by clicking the "+ New" button in the Custom Properties panel) and their type information in Python.

So if I create a custom property in the UI called my_property as a float on the Scene, I can then access the value with bpy.context.scene['my_property']. I can get some subtype information about that property by calling bpy.context.scene.id_properties_ui('my_property').as_dict() which will return this:

{"subtype": "NONE", "description": "Description goes here.", "min": 0.0, "max": 1.0, "soft_min": 0.0, "soft_max": 1.0, "step": 0.10000000149011612, "precision": 3, "default": 1.0}

The problem is that the id_properties_ui method only returns information about the subtype of the property, not the main type. It can be one of Float, Float Array, Integer, Integer Array, Boolean, Boolean Array, String, Data Block, or Python. How do I determine the main type in Python? Where is this stored?

enter image description here

$\endgroup$
1
  • $\begingroup$ type(bpy.context.scene['my_property']) will get you the plain old python ones but it will be more complicated for arrays and python expression types $\endgroup$
    – Gorgious
    Commented May 5 at 8:51

0

You must log in to answer this question.

Browse other questions tagged .