Rig

class Rig(config=None, meta=None)

Bases: object

Main entry class for creating and managing Hive rigs.

The Rig class is the primary interface for working with Hive rigging systems. It provides a complete lifecycle for character rig creation, from component management to final build and serialization. Each rig maintains its own scene hierarchy with a root node and meta node for tracking rig state and metadata.

Key Features:

  • Component creation and management

  • Template loading and saving

  • Build orchestration and validation

  • Scene integration with Maya

  • Serialization and version control

The rig follows a layered architecture where components are organized under a component layer node, which is a child of the rig root. This provides clean separation between different rig elements and enables efficient scene management.

Basic Usage:

# Create a new rig
rig = Rig()
rig.startSession("myCharacter")

# Add components
arm = rig.createComponent("arm", "leftArm", "L")
spine = rig.createComponent("spine", "spine", "C")

# Build stages - rig goes through distinct phases
rig.buildGuides()    # Build guide layer for positioning
rig.buildDeform()     # Build skeletal/deformation layer
rig.buildRigs()       # Build rig layer with controls
rig.polish()          # Final cleanup and optimization

# Save as template
rig.saveTemplate("/path/to/template.hive")

Working with Existing Rigs:

# Find rigs in scene
for rig in iterSceneRigs():
    print(f"Found: {rig.name()}")

# Load from template
rig = loadFromTemplate("/path/to/template.hive")
rig.startSession("loadedCharacter")

Component Management:

# Get all components
components = rig.components()

# Access specific component
arm = rig.component("arm", "L")

# Delete component
rig.deleteComponent("arm", "L")
Parameters:
  • config (configuration.Configuration or None) – The local configuration to use for this rig

  • meta (hivenodes.HiveRig or None) – The root hive meta node to use for this rig

Note

The rig manages its own component cache and scene state. Always use the rig’s methods to create, modify, or delete components rather than direct scene manipulation.

versionInfo()

Returns the build version info for the rig. Include, hive version, maya version, zoo version.

Return type:

dict[str, str]

property hiveVersion

Returns the Current rigs hive version it was built in.

Returns:

The hive version i.e. 1.0.0

Return type:

str

property meta

Returns the meta Node class for this rig Instance.

Returns:

The meta node that represents this rig instance.

Return type:

hivenodes.HiveRig

property blackBox

Returns True if any component is currently set to a blackbox.

Return type:

bool

iterComponents()

Generator function to iterate over all components in this rig, If the cache is valid then we use this otherwise the rig in the scene will be searched.

Return type:

collections.Iterable[component.Component]

startSession(name=None, namespace=None)

Starts a rig session for the given rig name, if the rig already exists in the scene then this rig is reinitialized for this rig instanced. This happens by searching the scene meta root nodes

Parameters:
  • name (str or HiveMeta) – the rig name to initialize, if it doesn’t already exist one will be created

  • namespace – The rig namespace

Type:

namespace: str

Returns:

the root meta node for this rig

Return type:

hivenodes.HiveRig

rootTransform()

Returns The root transform node of the rig i.e. the root HRC.

Return type:

zapi.DagNode

exists()

Returns True or False depending on if the meta node attached to this rig exists. Without the metanode the rig is no longer part of hive hence False

Return type:

bool

name()

Returns the name of the rig via the meta node

Returns:

the rig name

Return type:

str

rename(name)

Renames the current rig, this changes both the meta.name attribute.

Parameters:

name (str) – the new rig name

namingConfiguration()

Returns the naming configuration for the current Rig instance.

Return type:

namingutils.NameManager

buildState()

Returns the current build state which is determined by the very first component.

Returns:

The hive constant. NOT_BUILT, POLISH_STATE, RIG_STATE, SKELETON_STATE, GUIDES_STATE

Return type:

int

Returns the livelink state for the rig.

Return type:

bool

Sets up live linking between the guides and the deformation layer.

Parameters:

state (bool) – True if live link should be switched on.

createGroup(name, components=None)

Creates a component group on the component layer.

Parameters:
  • name (str) – The new component group

  • components (iterable(component.Component) or None) – The components to add or None

Returns:

True if the component group was added.

Return type:

bool

Raise:

errors.ComponentGroupAlreadyExists

addToGroup(name, components)

Adds the components to the component group.

Parameters:
  • name (str) – The component group name

  • components (iterable(component.Component)) – A list of component instances.

Returns:

True if at least one component added.

Return type:

bool

removeGroup(name)

Remove’s the entire component group and it’s children.

Parameters:

name (str) – The group name to remove.

Returns:

True if the group was removed.

Return type:

bool

removeFromGroup(name, components)

Removes a list of components from the component group.

Parameters:
  • name (str) – The group name to remove the component from

  • components (list(component.Component)) – A list of components to remove.

Returns:

True if the components were removed.

Return type:

bool

renameGroup(oldName, newName)

Renames a component group name.

Parameters:
  • oldName (str) – The old group name.

  • newName (str) – The new group name.

Returns:

True if the group was renamed

Return type:

bool

groupNames()

Returns a list of group names:

Returns:

a list of str representing the group name

Return type:

list(str)

iterComponentsForGroup(name)

Generator function to iterate over all the component instances of a group.

Parameters:

name (str) – The name of the group to iterate

Return type:

Generator[component.Component]

createComponent(componentType=None, name=None, side=None, definition=None)

Adds a component instance to the rig and creates the root node structure for the component. When a component is added it will always be parented to the component Layer dag node.

Parameters:
  • componentType (str) – the component type this is the className of the component

  • name (str) – the name to give the component

  • side (str) – the side name to give the component

  • definition (None or baseDef.ComponentDefinition) – component definition, this is set to None by default therefore it will load the definition for the component from file

Returns:

the instance of the component

Return type:

component.Component

clearComponentCache()

Clears the component cache which stores component class instances on this rig instance.

topologicalSortComponents(components)

Orders components based on their parent-child relationships using breadth-first traversal, with parentless components first.

Parameters:

components (list or Generator[component.Component]) – List or generator of components to order

Returns:

Ordered dictionary mapping components to their parents

Return type:

dict[component.Component, component.Component]

validateGuides(components=None)

Call the validate guides method on all the components in the rig and returns the results.

..note:

This method is only called explicitly and not automatically within hive. Useful for UI.

Parameters:

components (list[component.Component])

Returns:

Return type:

list[errors.ValidationComponentInfo]

buildGuides(components=None, buildContext=None)

Builds all the guides for the current initialized components, if the component already has a guide then this component is skip, see the component base class for more info.

Parameters:
  • components (list[component.Component] or None) – The components to build, if None then all components on the rig will be built.

  • buildContext (buildcontext.BuildContext or None) – The build context to report errors, logs and progress to. If None a throwaway context is created for the duration of this call.

setGuideVisibility(stateType, controlValue=None, guideValue=None, includeRoot=False)

Sets all component guides visibility.

Parameters:
  • stateType (int) – one of the following. constants.GUIDE_PIVOT_STATE, constants.GUIDE_CONTROL_STATE GUIDE_PIVOT_CONTROL_STATE.

  • controlValue (bool) – The guide control visibility state.

  • guideValue (bool) – The guide pivot visibility state.

  • includeRoot (bool) – Whether to override the root guide visibility. By default, if a component is the root then the visibility state will be True.

setComponentAnnotationVisibility(state)

Sets the component annotation visibility state if the component has a parent.

Parameters:

state (bool) – Visibility state for the annotations.

setGuideAnnotationVisibility(state)

Sets the visibility state for all annotations within a component.

Parameters:

state (bool) – Visibility state for the annotations.

buildDeform(components=None, buildContext=None)

Builds deform systems for the specified components.

Parameters:
  • components (list[Component]) – The list of components to build deform systems for. If not specified, builds deform systems for all components.

  • buildContext (buildcontext.BuildContext or None) – The build context to report errors, logs and progress to. If None a throwaway context is created for the duration of this call.

Returns:

True if successful, False otherwise.

Return type:

bool

buildRigs(components=None, buildContext=None)

Same as buildGuides() but builds the rigs, if theres no guide currently built for the component then the component definition will be used.

Parameters:

buildContext (buildcontext.BuildContext or None) – The build context to report errors, logs and progress to. If None a throwaway context is created for the duration of this call.

Todo:

deal with building without the guides

polish(buildContext=None)

Executes every component component.Component.polish() function .

Used to do a final cleanup of the rig beforehand off to animation.

Parameters:

buildContext (buildcontext.BuildContext or None) – The build context to report errors, logs and progress to. If None a throwaway context is created for the duration of this call.

controlDisplayLayer()

Returns The display layer for the controls.

Return type:

zapi.DisplayLayer or None

deleteGuides(buildContext=None)

Deletes all guides on the rig

Parameters:

buildContext (buildcontext.BuildContext or None) – The build context to report build script errors to. If None a throwaway context is created for the duration of this call.

deleteDeform(deleteJoints=True, buildContext=None)

Deletes all component rigs

Parameters:

buildContext (buildcontext.BuildContext or None) – The build context to report build script errors to. If None a throwaway context is created for the duration of this call.

deleteRigs(buildContext=None)

Deletes all component rigs

Parameters:

buildContext (buildcontext.BuildContext or None) – The build context to report build script errors to. If None a throwaway context is created for the duration of this call.

deleteComponents(deleteJoints=True, buildContext=None)

Deletes all components

Parameters:

buildContext (buildcontext.BuildContext or None) – The build context to report build script errors to. If None a throwaway context is created for the duration of this call.

deleteComponent(name, side, deleteJoints=True, buildContext=None)

Deletes all the current components attached to this rig

Parameters:

buildContext (buildcontext.BuildContext or None) – The build context to report build script errors to. If None a throwaway context is created for the duration of this call.

deleteControlDisplayLayer()

Deletes the current display layer for the rig.

Returns:

Whether the deletion was successful.

Return type:

bool

delete(deleteJoints=True, buildContext=None)

Deletes all the full rig from the scene

Parameters:

buildContext (buildcontext.BuildContext or None) – The build context to report build script errors to. If None a throwaway context is created for the duration of this call.

duplicateComponent(componentInstance, newName, side)

Duplicates the given component and adds it to the rig instance

Parameters:
  • component – The component to duplicate, this can be the component instance or a tuple, if a tuple is supplied then the first element is the name second is the side of the component to duplicate.

  • newName (str) – the new name for the duplicated component

  • side (str) – the new side for the duplicated component e.g. L

Returns:

The new component

Return type:

zoo.libs.hive.base.component.Component

duplicateComponents(componentData, buildContext=None)

Duplicates the given component data and returns the new components.

Parameters:
  • componentData (list[dict]) – List of component data dicts containing the component, name, and side of the component to duplicate.

  • buildContext (buildcontext.BuildContext or None) – The build context to report the builds to, if None a throwaway one is used.

Returns:

Dictionary of the new components keyed by the original name and side of the component.

Return type:

dict

mirrorComponents(componentData, buildContext=None)

Mirror the given components.

Parameters:
  • componentData (list[dict]) – A list of dictionaries containing component objects and metadata for mirroring.

  • buildContext (buildcontext.BuildContext or None) – The build context to report the builds to, if None a throwaway one is used.

Returns:

A dictionary containing the mirrored components and metadata for their transformation.

Return type:

dict

components()

Returns the full list of component classes current initialized in the scene

Return type:

list[zoo.libs.hive.base.component.Component]

rootComponents()

Returns all root components as a generator.

A component is considered the root if it has no parent.

Return type:

list[component.Component]

hasComponent(name, side='M')

Determines if the rig current

Parameters:
  • name (str) – The name of the component

  • side (str) – the side name of the component

Returns:

True if the component with the name and side exists

Return type:

bool

component(name, side='M')

Try’s to find the component by name and side, First check this rig instance in the component cache if not there then walk the components via the meta network until one is found. None will be return if the component doesn’t exist.

Parameters:
  • name (str) – the component name

  • side (str) – the component side name

Returns:

Returns the component or None if not found

Return type:

zoo.libs.hive.base.component.Component or None

componentsByType(componentType)

Generator Method which returns all components of the requested type name.

Parameters:

componentType (str) – The hive component type.

Returns:

Generator where each element is a component which has the requested type.

Return type:

list[component.Component]

componentFromNode(node)

Returns the component for the provided node if it’s part of this rig, otherwise Raise errors.MissingMetaNode if the node isn’t connected.

Parameters:

node (zapi.DGNode) – The DG and Dag node to search for the component.

Return type:

component.Component or None

Raise:

errors.MissingMetaNode

serializeFromScene(components=None)

Ths method will run through all the current initialized component and serialize them

Return type:

dict

saveConfiguration()

Serializes and saves the configuration for this rig on to the meta node. Use Rig.CachedConfiguration() to retrieve the saved configuration.

Returns:

The Serialized configuration.

Return type:

dict

cachedConfiguration()

Returns the configuration cached on the rigs meta node config attribute as a dict.

Returns:

The configuration dict.

Return type:

dict

componentLayer()

Returns the component layer instance from this rig by querying the attached meta node.

Return type:

hivenodes.HiveComponentLayer

deformLayer()

Returns the deform layer instance from this rig by querying the attached meta node.

Return type:

hivenodes.HiveDeformLayer

geometryLayer()

Returns the Geometry layer instance from this rig by querying the attached meta node.

Return type:

hivenodes.HiveGeometryLayer

selectionSets()
Returns:

Return type:

dict[str,:class:zapi.ObjectSet]

getOrCreateGeometryLayer()

Returns the geometry layer if it’s attached to this rig or creates and attaches one

Return type:

hivenodes.HiveGeometryLayer

getOrCreateDeformLayer()

Returns the deform layer if it’s attached to this rig or creates and attaches one

Return type:

hivenodes.HiveDeformLayer

getOrCreateComponentLayer()

Returns the component layer if it’s attached to this rig or creates and attaches one

Return type:

layers.ComponentLayer

alignGuides(rig, components)

Runs alignGuides for all provided guides.

This function appropriately disconnects components before aligning them and handles component container locking during the process.

Parameters:
  • rig (Rig) – The rig instance which the components belong to

  • components (list[component.Component]) – List of components to align

Returns:

None

rootByRigName(name, namespace=None)

Finds the root meta node with the name attribute matching the specified name.

Searches for a Hive rig meta node with the given name in the specified namespace. If no namespace is provided, searches in all namespaces.

Parameters:
  • name (str) – The rig name to search for

  • namespace (str or None) – The namespace to search within. Must be a valid namespace. If None, searches in all namespaces.

Returns:

The HiveRig meta node if found, otherwise None

Return type:

hivenodes.HiveRig or None

iterSceneRigMeta()

Generator function that iterates over every Hive rig Meta node in the scene.

This searches through all nodes in the scene to find Hive rig meta nodes.

Returns:

Iterator of HiveRig meta nodes found in the scene

Return type:

collections.Iterator[hivenodes.HiveRig]

Example

>>> for rig_meta in iterSceneRigMeta():
...     print(rig_meta.rigName())
iterSceneRigs()

Generator function that iterates over every Hive rig in the scene.

This searches through all meta node roots (Network Nodes) in the scene and checks for nodes with the “isHiveRoot” attribute.

Returns:

Iterator of Rig instances found in the scene

Return type:

collections.Iterator[Rig]

Example

>>> for rig in iterSceneRigs():
...     print(rig.name)
loadFromTemplateFile(filePath, name=None, rig=None)

Load a rig template from a JSON file.

This function reads a template from the specified JSON file and applies it to either the provided rig or a new rig instance.

Parameters:
  • filePath (str) – The absolute path to the template JSON file to load.

  • name (str or None) – The name for the new rig instance if created. If None and no rig is provided, defaults to “HiveRig”.

  • rig (Rig or None) – The rig instance to load the template onto. If None, a new rig instance will be created.

Returns:

The rig instance with the template loaded

Return type:

Rig

Raises:
  • IOError – If the template file cannot be read

  • ValueError – If the template data is invalid

loadFromTemplate(template, name=None, rig=None)

Loads a Hive template onto a rig.

This function applies the provided template data to either an existing rig or a new rig instance. The template should be a dictionary containing the rig configuration and component definitions.

Parameters:
  • template (dict) – The Hive template data structure containing rig configuration and components

  • name (str or None) – Name for the new rig if creating one. If None and no rig is provided, the name will be taken from the template.

  • rig (Rig or None) – Existing rig instance to apply the template to. If None, a new rig will be created.

Returns:

A tuple containing the rig instance and a dictionary of created components

Return type:

tuple[Rig, dict[str, component.Component]]

Raises:

ValueError – If there’s an issue with the template data or configuration

rigFromNode(node)

Finds and returns the Rig instance associated with the given node.

This function searches for a Hive rig by examining the meta nodes connected to the provided node. It traverses up the meta node hierarchy to find the root Hive rig meta node.

Parameters:

node (zapi.DGNode) – The node to find the associated rig for

Returns:

The Rig instance associated with the node

Return type:

Rig

Raises:
parentRig(metaNode)

Finds and returns the parent Rig instance for the given meta node.

This function traverses up the meta node hierarchy to find the first parent meta node that is a Hive rig root node (has the isHiveRoot attribute set to True).

Parameters:

metaNode (base.MetaBase) – The meta node to start searching from

Returns:

The parent Rig instance if found, otherwise None

Return type:

Rig or None

componentFromNode(node, rig=None)

Finds and returns the component associated with the given node.

This function searches for a component by examining the meta nodes connected to the provided node. It can search within a specific rig if provided, otherwise it will search all rigs in the scene.

Parameters:
  • node (zapi.DGNode) – The node to find the component for

  • rig (Rig or None) – Optional Rig instance to search within. If None, searches all rigs.

Returns:

The component associated with the node

Return type:

component.Component

Raises:
componentMetaNodeFromNode(node)

Finds and returns the component meta node associated with the given node.

This function attempts to find a component meta node by walking the dependency graph downstream from the given node. It first checks if the node itself is a meta node, then checks connected meta nodes, and finally traverses up the meta node hierarchy.

Note

This function is for internal use only.

Parameters:

node (zapi.DGNode) – The node to find the component meta node for

Returns:

The component meta node if found, otherwise None

Return type:

base.MetaBase or None

Raises:

ValueError – If the node is not connected to any meta node

componentsFromSelected()

Gets components associated with the currently selected nodes in the scene.

This function finds all Hive components that are associated with the currently selected nodes in the Maya scene. Each component can be associated with multiple selected nodes.

Returns:

A dictionary mapping components to lists of selected nodes that belong to them

Return type:

dict[component.Component, list[zapi.DagNode]]

Example

>>> selected_components = componentsFromSelected()
>>> for instance, nodes in selected_components.items():
...     print(f"Component: {instance.name()}")
...     for node in nodes:
...         print(f"  - {node.fullPathName()}")
componentsFromNodes(nodes)

Gets components associated with the given list of nodes.

This function finds all Hive components that are associated with the provided nodes. Each component can be associated with multiple nodes. Nodes that are not associated with any component are silently ignored.

Parameters:

nodes (list[zapi.DGNode]) – List of nodes to find components for

Returns:

A dictionary mapping components to lists of nodes that belong to them

Return type:

dict[component.Component, list[zapi.DagNode]]

Example

>>> nodes = zapi.selected()
>>> components = componentsFromNodes(nodes)
>>> for instance, component_nodes in components.items():
...     print(f"Component: {instance.name()}")
...     for node in component_nodes:
...         print(f"  - {node.fullPathName()}")
buildScriptContext(rig, buildScriptType, buildContext=None, **kwargs)

Executes all build scripts assigned in the configuration.buildScript.

If each build script class registered contains a method called preGuideBuild() :param rig: The rig instance that owns the build scripts :type rig: Rig :param buildScriptType: Type of build script to be executed :type buildScriptType: int :param buildContext: The build context to report build script errors/progress to. A build script hook that raises is recorded on this context, attributed to the script’s id, then re-raised – a broken build script still halts the build, but is no longer indistinguishable from a bare traceback. :type buildContext: buildcontext.BuildContext or None :rtype: Generator

setupRigMirroring(rig, components)
Parameters:
  • rig (Rig) – The rig instance that owns the components

  • components (list[component.Component]) – A list of components