diff --git a/modules/extensions_framework/__init__.py b/modules/extensions_framework/__init__.py index 08bd57e7e4e6d33255f8b0475eb6d6ab0a6608ca..f842f5aeff6009561aaa63dfa0c748c7a1b76199 100644 --- a/modules/extensions_framework/__init__.py +++ b/modules/extensions_framework/__init__.py @@ -115,6 +115,30 @@ def init_properties(obj, props, cache=True): # Silently skip invalid entries in props continue +def ef_initialise_properties(cls): + """This is mostly copied from plugin.plugin.install + This is a class decorator that should be used on + sub-classes of declarative_property_group in order + to ensure that they are initialised when the addon + is loaded. + + """ + + for property_group_parent in cls.ef_attach_to: + if property_group_parent is not None: + prototype = getattr(bpy.types, property_group_parent) + if not hasattr(prototype, cls.__name__): + init_properties(prototype, [{ + 'type': 'pointer', + 'attr': cls.__name__, + 'ptype': cls, + 'name': cls.__name__, + 'description': cls.__name__ + }]) + + init_properties(cls, cls.properties) + + return cls class declarative_property_group(bpy.types.IDPropertyGroup): """A declarative_property_group describes a set of logically @@ -135,6 +159,15 @@ class declarative_property_group(bpy.types.IDPropertyGroup): """ + """This property tells extensions_framework which bpy.type(s) + to attach this IDPropertyGroup to. If left as an empty list, + it will not be attached to any type, but its properties will + still be initialised. The type(s) given in the list should be + a string, such as 'Scene'. + + """ + ef_attach_to = [] + """This list controls the order of property layout when rendered by a property_group_renderer. This can be a nested list, where each list becomes a row in the panel layout. Nesting may be to any depth. diff --git a/modules/extensions_framework/plugin.py b/modules/extensions_framework/plugin.py index 27b4587178346990ced998ea2b5943654b764dbc..a548a84fca2278573d07f7f79766910e1c7f8fea 100644 --- a/modules/extensions_framework/plugin.py +++ b/modules/extensions_framework/plugin.py @@ -82,7 +82,7 @@ class plugin(object): if call_init: init_properties(property_group, property_group.properties) - log('Extension "%s" initialised' % r_class.bl_label) + log('Extension "%s" initialised' % r_class.__name__) @classmethod def uninstall(r_class):