robot_designer_plugin.core.property module

class robot_designer_plugin.core.property.PropertyGroupHandlerBase[source]

Bases: object

Base class for wraps a bpy.types.PropertyGroup-derived class object. Blender uses those classes as templates to dynamically generate properties for existing types (such as bpy.types.Object or bpy.types.Bone) This, however, makes developing cumbersome. Dynamically created properties are usually accessed by:

context.current_object.plugin.propertygroup1.propertygroup2.property

which cannot be resolved during programming time (as it is dynamically generated and aggregated to the blender objects. Using this wrapper class, you can build a delegation class structure that is known during programming and, therefore, for code completion and static analysis.

Example:

class GuiProperties(PropertyGroupHandlerBase):
def __init__(self):
    self.selected_mesh = PropertyHandler(StringProperty(name="meshName"))

class GlobalProperties(PropertyGroupHandlerBase):
    def __init__(self):
        self.gui_properties = GuiProperties()

global_properties = GlobalProperties()
global_properties.register(bpy.types.Scene)

When calling the register() method, the plugin core creates the class templates for Blender dynamically and registeres them to the software.

register(btype, parent=[])[source]

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. bpy.types.Object or bpy.types.Bone) @param parent: For traversing nested groups @return: Reference to the generated bpy.types.PropertyGroup-derived class (not used by the user).

class robot_designer_plugin.core.property.PropertyHandler(property)[source]

Bases: object

Wraps a Blender property factory functions (e.g., bpy.props.StringProperty(), bpy.props.FloatProperty() or bpy.props.IntProperty()). Use it in a PropertyGroupHandlerBase instance. E.g.:

class GuiProperties(PropertyGroupHandlerBase):
    def __init__(self):
        self.selected_mesh = PropertyHandler(StringProperty(name="meshName"))
get(obj)[source]

Resolves and returns the registered property given a reference to the (correct) object type.

In the example in PropertyGroupWrapper:

mesh name = global_properties.gui_properties.selected_mesh.get(context.scene)
Parameters

obj – A Blender object with additional properties defined by the wrapper classes.

Returns

The property.

prop(obj, layout, *args, **kwargs)[source]

Resolves and renders a registered property on a GUI bpy.types.UILayout object given a reference to the (correct) object type.

In the example in PropertyGroupWrapper:

def draw(context, layout):
    global_properties.gui_properties.selected_mesh.prop(context.scene)

Additional positional arguments and keyword arguments are passed to bpy.types.UIlayout.prop()

Parameters
  • obj – A Blender object with additional properties defined by the wrapper classes.

  • layout – A bpy.types.UIlayout reference.

Resolves and renders a bpy.types.UIlayout.prop_search() connected to a registered property on a GUI bpy.types.UILayout object given a reference to the (correct) object type.

In the example in PropertyGroupWrapper:

def draw(context, layout):
    global_properties.gui_properties.selected_mesh.prop_search(context.scene, layout,
                                         bpy.data,'objects', icon='VIEWZOOM', text='')

Additional positional arguments and keyword arguments are passed to bpy.types.UIlayout.prop()

Parameters
  • obj – A Blender object with additional properties defined by the wrapper classes.

  • layout – A bpy.types.UIlayout reference.

set(obj, value)[source]