9
$\begingroup$

I sometimes find it difficult to recall what type of properties a Blender user or addon has, as well as what choices it brings. ("Set Driver", etc.)

I know there are clear differences between how to add new custom properties, but I'm still not clear on what the meaning is of things such as ID property, RNA property, or custom properties, when a Blender user referernces them (In forum or here).

Property A: We can add new property of obj, armature, or any IDdata,

obj['prop_a'] = 3.0 #(I added prop_a for current active obj)

https://docs.blender.org/api/blender_python_api_current/info_quickstart.html#custom-properties

In this document, it is called a "Custom property".

We can access this property by using a dictonary key. But we cannot access it by "obj.prop_a".

Then:

PropertyB: use bpy.props then add it for object

bpy.types.Object.prop_b = bpy.props.FloatProperty(name="Test Prob")
bpy.data.objects["Cube"].prop_b = 0.5

https://docs.blender.org/api/blender_python_api_current/bpy.props.html#module-bpy.props

In this document, the property is called a "custom property" also.

If it has no RNA_UI, then we cannot edit values such as min, max, etc. It is labelled as "API defined".

So what is the formal (or official) name, when we distinguish these properties for general use? And while hoping to find clear documentation which guides us about these distinctions and details to a greater extent (so that we can make a script)?

And I often see users make offhand reference to custom properties, ID properties, or RNA properties. But which is which? I'd really appreciate if someone could elaborate on this (or tell me a link which can guide me toward getting a better understanding of these things.)

$\endgroup$
1
  • $\begingroup$ Re custom properties AFAIK would call any non API defined property custom... eg ob["foo"] or ob.foo. Not ob.location as that is already a member of bpy.types.Object For want of a better name could call ob["foo"] an instance property, since it is (most likely) only defined on one object. Whereas setting up ob.foo makes the property available to all objects of that type. $\endgroup$
    – batFINGER
    Commented May 28, 2019 at 7:40

1 Answer 1

1
$\begingroup$

There are essentially three types of properties in Blender. It seems like their distinction has always been a bit murky.

  • built-in properties. These are defined in C code and exposed to Python through the RNA system. They could be called RNA properties, although I don't know if the term is typically used in that sense. These properties are always there and often have some restrictions in their usage. They can only be accessed as a Python attribute.
  • Registered ID properties. They are defined in Python code using bpy.props.*. Originally they could only be registered on ID types (datablocks such as Objects, Meshes, etc.), hence the name. Now, confusingly, there are some other types such as Bones, and Sequences, that can also hold ID properties. They can be accessed as a Python attribute. Using the subscript operator instead succeeds but gives you "bpy id prop" object instead of the value.
  • Custom ID properties. They are usually created through the user interface, but Python can also be used for that. Internally, these are also ID properties, so they can be created on the same datablocks and other types as registered ID properties. They can only be accessed by a subscript.

If you have a Python object, you can list the first two types of properties through obj.bl_rna.properties and distinguish them by obj.bl_rna.properties['name'].is_runtime. RNA_UI helps to distinguish between custom ID properties that have been created or edited through the UI and those that have been set by Python.

$\endgroup$

You must log in to answer this question.

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