The documentation on
If the class has a register class method it will be called before registration.
How should this method be declared? What arguments will it be given?
A class method takes at least one argument - the class itself. Here,
register (and its counterpart,
unregsiter) do not take anything else, so you must declare them this way:
@classmethod def register(cls): pass @classmethod def unregister(cls): pass
You have a good example of their usage in Cycles'
class CyclesRenderSettings(bpy.types.PropertyGroup): @classmethod def register(cls): bpy.types.Scene.cycles = PointerProperty( name="Cycles Render Settings", description="Cycles render settings", type=cls, ) cls.device = EnumProperty( name="Device", description="Device to use for rendering", items=enum_devices, default='CPU', ) # ... and so on adding properties to cls @classmethod def unregister(cls): del bpy.types.Scene.cycles
That way, you can embed the definition of your propertygroup and handle its container’s creation and deletion inside the class, instead of having to create/delete
bpy.types.Scene.cycles in the global (un)register funcs.