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 rigmeta (
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:
- property meta¶
Returns the meta Node class for this rig Instance.
- Returns:
The meta node that represents this rig instance.
- Return type:
hivenodes.HiveRig
- 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:
- 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:
- setLiveLink(state)¶
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.
- addToGroup(name, components)¶
Adds the components to the component group.
- removeGroup(name)¶
Remove’s the entire component group and it’s children.
- removeFromGroup(name, components)¶
Removes a list of components from the component group.
- renameGroup(oldName, newName)¶
Renames a component group name.
- 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:
- 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:
- 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
] orzoo.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:
- duplicateComponents(componentData)¶
Duplicates the given component data and returns the new components.
- 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:
- mirrorComponents(componentData)¶
Mirror the given components.
- components()¶
Returns the full list of component classes current initialized in the scene
- Return type:
- 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
- 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:
- Returns:
Returns the component or None if not found
- Return type:
- 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:
- 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:
- cachedConfiguration()¶
Returns the configuration cached on the rigs meta node config attribute as a dict.
- Returns:
The configuration dict.
- Return type:
- 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”
- 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:
- 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:
- 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:
- 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 fromrig – If a Rig instance has been passed then the component will be searched on that Rig.
- Type:
Rig
or None- Return type:
- 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
]]