2011-02-18 14:27:18 +00:00
|
|
|
"""
|
|
|
|
Assigning to Existing Classes
|
|
|
|
+++++++++++++++++++++++++++++
|
|
|
|
|
|
|
|
Custom properties can be added to any subclass of an :class:`ID`,
|
|
|
|
:class:`Bone` and :class:`PoseBone`.
|
|
|
|
|
|
|
|
These properties can be animated, accessed by the user interface and python
|
2015-04-24 14:08:31 +01:00
|
|
|
like Blender's existing properties.
|
2022-08-12 16:21:11 +02:00
|
|
|
|
|
|
|
.. warning::
|
|
|
|
|
|
|
|
Access to these properties might happen in threaded context, on a per-data-block level.
|
|
|
|
This has to be carefully considered when using accessors or update callbacks.
|
|
|
|
|
|
|
|
Typically, these callbacks should not affect any other data that the one owned by their data-block.
|
|
|
|
When accessing external non-Blender data, thread safety mechanisms should be considered.
|
|
|
|
|
2011-02-18 14:27:18 +00:00
|
|
|
"""
|
|
|
|
|
|
|
|
import bpy
|
|
|
|
|
|
|
|
# Assign a custom property to an existing type.
|
2019-03-22 00:07:06 +11:00
|
|
|
bpy.types.Material.custom_float = bpy.props.FloatProperty(name="Test Property")
|
2011-02-18 14:27:18 +00:00
|
|
|
|
|
|
|
# Test the property is there.
|
|
|
|
bpy.data.materials[0].custom_float = 5.0
|