Register Property Groups#
Let’s learn how we can create a new Property Group by using our Register utility and the Property helper class from addon_utils
submodule.
Examples#
Child PropertyGroup#
‘Child’ property groups are meant to be nested in other ‘Child’ or ‘Root’ property groups.
from .addon_utils import Register, Property
@Register.PROP_GROUP.CHILD
class ChildPropertyGroup:
some_bool: Property.BOOL()
some_string: Property.STRING()
Root PropertyGroup#
A root Property Group that will be directly atached to a Blender type in bpy.types
.
from .addon_utils import Register, Property
@Register.PROP_GROUP.ROOT.WINDOW_MANAGER('uvflow') # If name is not specified, the module name will be used.
class RootWMPropertyGroup:
test_bool: Property.BOOL()
test_int: Property.INT()
test_float: Property.FLOAT()
test_str: Property.STRING(default='UVFlow')
# Here we reference the previously created PropertyGroup so it is a child of this PG.
child_pg: Property.COLLECTION(ChildPropertyGroup)