I'm currently trying to store API and their values into a .json. and as i'm browsing through blender API sometimes instead of having the value, We can get a <bpy_struct> object

For example

C.object.bl_rna.properties["color"] # or through C.object.bl_rna.properties.items()

will get me <bpy_struct, FloatProperty("color") at 0x00007FF6C4A67210>

What is this Type? How is it used? How can I get it's value instead?


1 Answer 1


Property definitions saved in blender rna.

When we define a prop with bpy.props the methods are akin to python's property method, extended to save the details in the blend files rna. (From the geneticists mumbo jumbo)

All the things we define in the definition funcion, in this case FloatVectorProperty are stored here. The value when set is stored as a custom property in the file.

Even tho we don't need to define Object.color it's very, very similar to as if we defined

>>> from bpy.props import FloatVectorProperty
>>> bpy.types.Object.xcolor = FloatVectorProperty(
...         size=4,
...         default=(1, 1, 1, 1),
...         )

>>> C.object.bl_rna.properties['xcolor']
<bpy_struct, FloatProperty("xcolor") at 0x7fa4ee68d288>

Which looks just like

>>> C.object.bl_rna.properties["color"]
<bpy_struct, FloatProperty("color") at 0xc110c20>

Instance value

>>> C.object.color

>>> C.object.color[:]
(1.0, 1.0, 1.0, 1.0)

Some defaults.

>>> C.object.bl_rna.properties["color"].default

>>> C.object.bl_rna.properties["color"].array_length

The array's default value

>>> C.object.bl_rna.properties['color'].default_array
<bpy_float[4], FloatProperty.default_array>

>>> C.object.bl_rna.properties['color'].default_array[:]
(1.0, 1.0, 1.0, 1.0)

You must log in to answer this question.

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