< Process‎ | Addons‎ | Rigify

UI Script Generator

Every generated rig comes with a Python script that implements a set of rig-specific UI panels. The generation of this script is managed by the ScriptGenerator generator plugin.

The script consists of a set of utility functions and operators, followed by the panels themselves.


An instance of this class implements the generation of the script, and is accessible as generator.script or rig.script.

Utility Code

These methods are used to add utility code to the script, and register it when necessary.

All string lists added by these methods are concatenated together and filtered for duplicates before adding to the script. This allows easily sharing code between rigs without duplication by sharing code strings.

Adds module import lines to the script.
Add utility code to the script.
Add class names to be registered in the module register function.
Add function names to be added to the driver function namespace.
script.register_property(name, definition)
Add a custom property to be registered.


script.add_imports(['import math'])

def test_add(a, b):
  return a + b



script.register_property('Object.test_prop', '''bpy.props.StringProperty(name="test")''')

It is recommended to store the string lists used in calls to these functions in module global variables, in order to allow other modules to easily share the code later by using the same globals.

UI Panel Code

The script provides a UI panel that shows properties and operators relevant for the currently selected bones of the rig. These methods are used to generate the code for it.

Directly adds code to the panel. This method is deprecated and provided only for compatibility with legacy code.
script.panel_with_selected_check(rig, control_names)
Returns a PanelLayout object for generating a section of the panel belonging to the specified rig, and shown when the specified controls are selected. Repeated calls with the same parameters return the same panel object.
The sub-panels are ordered based on the sequence of the calls to this method, with panels belonging to the same rig always placed adjacent to each other.


Objects of this class are used to generate the panel code in a structured way, resembling the standard UILayout code.

The methods of the class accept arbitrary keyword parameters, denoted with '...', which are converted to strings and added verbatim to the generated UILayout calls.

Property referencing the ScriptGenerator that owns the panel.
panel.custom_prop(bone_name, prop_name, ...)
Generates a layout.prop call for the specified custom property of the specified bone.
panel.operator(operator_name, properties=None, ...)
Generates a layout.operator call, invoking the specified operator. The properties dictionary may be provided to assign input values to the properties of the operator itself.
The operator name may contain '{rig_id}' to automatically include the unique ID string of the rig.
Generates a layout.row call, and returns a PanelLayout object representing the sub-panel.
Generates a layout.column call, and returns a PanelLayout object representing the sub-panel.
Generates a layout.split call, and returns a PanelLayout object representing the sub-panel.