def register(self, btype, parent=[]):
"""
Register the wrapped property group to blender. This needs only be called for property groups directly
assigned to a blender type. Nested groups are automatically registered.
.. todo::
Register should use the standard registration mechanism of PluginManager. Right now, however,
this would break the current registration process. This will be done once the properties for
the robot designer have been clarified and migrated to this representation.
@param btype: Blender type (e.g. :class:`bpy.types.Object` or :class:`bpy.types.Bone`)
@param parent: For traversing nested groups
@return: Reference to the generated :class:`bpy.types.PropertyGroup`-derived class (not used by the user).
"""
if bpy.app.version == 'Mockup':
return
newPropertyGroup = type(self.__class__.__name__ + "_unwrapped", (bpy.types.PropertyGroup,), {})
for attr in self.__dict__.items():
if isinstance(attr[1], PropertyHandler):
attr[1].property[1]['attr'] = attr[0]
# print(attr[0], attr[1].d)
property=attr[1].property
setattr(newPropertyGroup, attr[0], property) # property[0](**property[1]))
attr[1].reference = parent + [attr[0]]
elif isinstance(attr[1], PropertyGroupHandlerBase):
pg = attr[1].register(None, parent + [attr[0]])
print(type(pg), pg.__bases__)
p = PointerProperty(type=pg)
p[1]['attr'] = attr[0]
setattr(newPropertyGroup, attr[0], p)
core_logger.debug("Registering generated property group: %s", newPropertyGroup.__name__)
bpy.utils.register_class(newPropertyGroup)
PluginManager._registered_properties.append((newPropertyGroup,btype))
if btype:
setattr(btype,'RobotDesigner',
bpy.props.PointerProperty(type=getattr(bpy.types, newPropertyGroup.__name__)))
core_logger.debug("Assigning property to: %s", btype)
return newPropertyGroup
评论列表
文章目录