Rig

class Rig(config=None, meta=None)

Bases: object

Main entry class for any given rig, The class allows for the construction and deconstruction of component every rig will have a root node and a meta node. when the first component is built a component layer node wil be generated this is a child of the root and will contain all built components.

r = Rig()
r.startSession("PrototypeRig")
r.components()
# result: []
proto = r.createComponent("EmptyComponent", "Prototype", "M")
print proto
# result: zoo.libs.hive.library.components.EmptyComponent
r.components()
r.rename("NewRig")
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

property hiveVersion

Returns the Current rigs hive version it was built in.

Returns:

The hive version ie. 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 ie. 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 instance

clearComponentCache()

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

buildGuides(components=None)

Builds all the guides for the current initialised 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.

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.

buildDeform(components=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.

Returns:

True if successful, False otherwise.

Return type:

bool

buildRigs(components=None)

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

Todo:

deal with building without the guides

polish()

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

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

controlDisplayLayer()

Returns The display layer for the controls.

Return type:

zapi.DGNode or None

deleteGuides()

Deletes all guides on the rig

deleteDeform()

Deletes all component rigs

deleteRigs()

Deletes all component rigs

deleteComponents()

Deletes all components

deleteComponent(name, side)

Deletes all the current components attached to this rig

deleteControlDisplayLayer()

Deletes the current display layer for the rig.

Returns:

Whether the deletion was successful.

Return type:

bool

delete()

Deletes all the full rig from the scene

duplicateComponent(component, newName, side)

Duplicates the given component and adds it to the rig instance

Parameters:
  • component (tuple[zoo.libs.hive.base.component.Component] or zoo.libs.hive.base.component.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 eg. L

Returns:

The new component

Return type:

zoo.libs.hive.base.component.Component

duplicateComponents(componentData)

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.

Returns:

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

Return type:

dict

mirrorComponent(comp, side, translate, rotate, duplicate=True)

Mirrors the provided component.

A new component will be created only if duplicate=True is set which is the default. When duplicate is False then the provided component will be mirrored in place.

Parameters:
  • comp (component.Component) – The component to mirror.

  • side (str) – The side name for the component only when duplicating.

  • translate (tuple) – The axis to mirror on ,default is (“x”,).

  • rotate (str) – The mirror plane to mirror rotations on, supports “xy”, “yz”, “xz”, defaults to “yz”.

  • duplicate (bool) – Whether the component should be duplicated then mirrored.

Return type:

dict

mirrorComponents(componentData)

Mirror the given components.

Parameters:

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

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:

layers.ComponentLayer

deformLayer()

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

Return type:

layers.DeformLayer

geometryLayer()

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

Return type:

layers.GeometryLayer

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

buildScriptContext(buildScriptType, **kwargs)

Executes all build scripts assigned in the configuration.buildScript.

If each build script class registered contains a method called preGuideBuild()

alignGuides(rig, components)

Runs alignGuides for all provided guides. This function appropriately disconnects components before aligning.

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

  • components (list[component.Component]) –

rootByRigName(name, namespace=None)

Finds the root meta node with the name attribute value set to “name”

Parameters:
  • name (str) – the rig name

  • namespace (str) – the namespace to search for the hive rig root meta node. must be valid namespace

Return type:

hivenodes.HiveRig

iterSceneRigMeta()

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

Returns:

Returns the rig instance

Return type:

collections.Iterator[hivenodes.HiveRig]

iterSceneRigs()

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

This is done by looping the metaNode roots(Network Nodes) and check if it has an attribute called “isHiveRoot”

Returns:

Returns the rig instance

Return type:

collections.Iterator[Rig]

loadFromTemplateFile(filePath, name=None, rig=None)
Parameters:
  • filePath (str) – The absolute path to the template json file to load.

  • name (str) – The name for the new rig instance if created, defaults to “HiveRig”.

  • rig (Rig or None) – The rig to load the components from template on to. if no rig provided then a new instance will be created.

Returns:

Returns the rig instance

Return type:

collections.Iterator[Rig]

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

Loads the hive template on to a rig.

Parameters:
  • template (dict) – The hive Template data structure.

  • name (str) – New rig Name, Only used if a rig isn’t provided.

  • rig (Rig or None) – An existing rig Instance, if None a new rig will be created.

Returns:

The New or provided rig instance and a list of newly created components.

Return type:

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

rigFromNode(node)

Get rig from node

Parameters:

node (zapi.DGNode) – The dag node to find the rig from

Returns:

The rig

Return type:

Rig

parentRig(metaNode)

Returns the meta node representing the parent rig.

Parameters:

metaNode (base.MetaBase) – The meta base class.

Returns:

The Rig instance found to be the parent of the metanode

Return type:

Rig or None

componentFromNode(node, rig=None)

Attempts to find and return the attached component class of the node.

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

  • rig – If a Rig instance has been passed then the component will be searched on that Rig.

Type:

Rig or None

Return type:

Component

Raises:

ValueError, Will raise when it cant find a meta node or the metanode is not a valid hive node.

componentMetaNodeFromNode(node)

This method attempts to resolve the component meta node by walking the DG downstream of the given node.

Note

Internal use only.

Parameters:

node (zapi.DGNode) – The zapi node instance.

Returns:

The Meta node class or None.

Return type:

base.MetaBase or None

componentsFromSelected()

Components from selected in the scene

Return type:

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

componentsFromNodes(nodes)

Components from selected in the scene

Return type:

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