Component Utilities

artv2.utilities.component_utilities

author:Jeremy Ernst
description:This module contains functions for returning information specific to components or functions that operate specifically on components.
check_for_children(joint)[source]

Checks if the given joint has any child components that are using it as their parent.

Parameters:joint (str) – Name of joint to check.
Returns:Returns a list of components that were children of the joint.
Return type:str, []
check_for_mirror_parent(joint)[source]

Search the component that created the given joint to see if it has a mirror_component. If so, find the matching mirrored joint to the given joint. For example, If the given joint is thigh_l, we can find out if the leg_l_metadata node has a mirror component. If it does (leg_r_metadata), we find a matching joint in that component (thigh_r).

Parameters:joint – Joint name to search for a mirrored match
Returns:Name of matching mirrored joint if found.
constrain_joints_to_movers()[source]

Constrains all deformation joints to their respective mover.

create_duplicate_instance(network_node, prefix, suffix)[source]

Create a new module instance using the class name of the passed in network node.

Parameters:
  • network_node – Component network node to pull class info off of
  • prefix – Prefix to create the new instance with
  • suffix – Suffix to create the new instance with
Returns:

instance of component class

detect_joint_conflicts(joints, all_joints, inst)[source]

When creating a component, detects if the component will create joints with names that other components also create. This was mostly implemented to handle the edge case of a biped leg and hind leg both being present in the scene with the same prefix and/or suffix.

Parameters:
  • joints – The created joints of the newly built component.
  • all_joints – All joints from other components in the scene.
  • inst – The instance of the component class
Returns:

Returns True if there were conflicts present, False otherwise.

find_associated_mover_from_joint(joint_name, return_offset=False)[source]

Gets the name of the joint mover (global, but offset if global doesn’t exist) that corresponds to the given name.

Parameters:
  • joint_name (str) – The name of the joint whose corresponding mover to search for.
  • return_offset (bool) – Whether to explicitly return the offset mover instead of the global mover.
Returns:

The name of the joint mover that corresponds to the joint name.

Return type:

str

find_mover_data_from_name(inst, name)[source]

Finds the global mover(s), offset mover(s), and guide joint(s) associated with the given name. :param inst: The component instance :param name: Name to search nodes for :return: List of nodes that contain search key [[global movers], [offset movers], [joints]]

find_owning_component(joint)[source]

Given a joint, find which component the joint belongs to (responsible for creating the joint) and return the instance of that component class.

Parameters:joint (str) – name of the joint
Returns:instance of component class that created given joint
fix_dependencies(dependencies)[source]

Fix dependencies of components that are parented under a component that has been changed or removed in a way that affects other components, and set the parent of the affected components to the root.

Parameters:dependencies – List of components that have been impacted by another component changing or being removed.
Returns:Return a string list that details which components have had their root set to as their parent.
get_all_component_names()[source]

Returns a dictionary of all unique names of components in the scene. The value of each key is the metanode for that component.

Returns:Dictionary of component names with their corresponding metanodes
get_all_created_joints()[source]

Get all created joints from all components.

Returns:Returns a list of all joints that components will or have created.
Return type:str, []
get_all_rig_asset_nodes()[source]

Returns all rig asset (character) nodes.

Returns:A list (str) of all rig asset network node names.
get_available_components()[source]

Gets all component classes that are available for installing into a scene.

Returns:Dictionary of components where the key is the nice name of the component, and the value is a list containing the category, the module path, and the class name.
get_component_instance(network_node)[source]

Given a network node for a module, create an instance of the module and return it.

Parameters:network_node (PyNode) – The name of the network node to gather the necessary information from to create an inst.
Returns:Module instance
Return type:class.instance
get_joint_labels(network_node)[source]

Finds not only the created joints for a component, but their base labels, the guide joints, and the offset mover. This information is then returned in a dictionary with the format of:

{base_label: [created_joint, connected_joint, offset_mover]}
Parameters:network_node (str) – The network node for the component
Returns:Dictionary of joint data {base_label: [created_joint, connected_joint, offset_mover]}
get_mirror_components()[source]

Returns a dictionary of components that have mirrors, wherein the format is (key = component, value = mirror).

Returns:dictionary of components with their mirrors
get_rig_asset_node()[source]

Returns the network node for the entire rig asset. If more than one asset node exists, an exception will be raised.

Returns:Network node name (str) that represents the entire asset.
get_top_level_mover(node)[source]

Gets the top-most global mover of a module.

Parameters:node (pymel.core.PyNode) – PyNode of the mover group for the module.
Returns:Returns the name of the top-most global joint mover of the module.
mirror_top_mover_grp(source_inst, mirrored_inst, mirror_attr='scaleX')[source]

Because the top mover group of a component is constrained in all attributes, special consideration needs to be made when initially creating a mirror of a component so that any values that have been added to the top mover group by its parent mover get mirrored over to the newly mirrored instance. In this case, it’s a fairly brute force approach where a locator is created at the source group’s location, then grouped and scaled across the world origin. The mirrored group is then snapped to that locator.

Parameters:
  • source_inst – instance of class that has created a mirror of itself.
  • mirrored_inst – instance of the mirrored class.
  • mirror_attr – which attribute to scale when mirroring the group.
pin_all_components(pin=True)[source]

Pins all components in place, so that their parents do not affect them.

Parameters:pin – Whether or not to pin or unpin.
return_all_components()[source]

Returns all network nodes belonging to components.

Returns:A list (str) of all rig module network node names.
setup_global_scale(mover)[source]

Sets up an aliasAttr so that only uniform scale is possible.

Parameters:mover (str) – Name of the node to setup the uniform scale.
unconstrain_joints_to_movers()[source]

Removes constraints on all deformation joints from their respective mover.

validate_asset_name(name)[source]

Ensures that the given name is a valid name for Maya. :param str name: The name to validate. :return: Returns True if name is valid, otherwise False.

validate_prefix(metanode, prefix)[source]

Ensures that the given prefix is a valid name for Maya, as well as ensuring it has a trailing underscore. Also ensures that no other module exists with the new name, factoring in the adjusted prefix.

Parameters:
  • metanode – The rig module’s network node name.
  • prefix – The prefix to validate.
Returns:

Returns a valid prefix as a string. If the prefix was invalid, returns False

validate_suffix(metanode, suffix)[source]

Ensures that the given suffix is a valid name for Maya, as well as ensuring it has a leading underscore. Also ensures that no other module exists with the new name, factoring in the adjusted suffix.

Parameters:
  • metanode – The rig module’s network node name.
  • suffix – The suffix to validate.
Returns:

Returns a valid suffix as a string. If the suffix was invalid, returns False