Register Properties#
Let’s learn how we can add a Property to a Blender type in bpy.types
by using our Register utility and the Property helper class from addon_utils
submodule.
Examples#
Single Property#
from bpy.types import Object
from .addon_utils import Register, Property
Register.PROP(Object, 'test_bool', Property.BOOL(name="Test", default=True))
Multiple Properties (Batch)#
Adds several new properties in batch to bpy.types.WindowManager.
from bpy.types import Object, WindowManager
from .addon_utils import Register, Property
Register.PROP_BATCH(WindowManager,
test_bool = Property.BOOL(),
test_rgba = Property.COLOR_RGBA(default=(1, 1, 0, 1)),
test_vector3 = Property.VECTOR_3(default=(0, 0, 0)),
test_filepath = Property.FILEPATH(),
test_pointer_object = Property.POINTER(Object)
)