Utilities.utils

Author: Jeremy Ernst

Functions

class Utilities.utils.MirrorTable[source]

Bases: object

__init__()[source]

In Progress: Used to build mirror table for pose mirroring. Currently run by hand, but needs to be run after rig build. Also, control invert values need to be manually set, and this needs to be changed. Invert axis attributes should be added before this, and the values set on the controls after control creation.

Utilities.utils.brushStartSetup(brushNode)[source]
Utilities.utils.convertCurvesToStrokes(curve)[source]
Utilities.utils.create_module_dict()[source]

Creates and returns a dictionary of module network node and module name pairs.

Utilities.utils.deleteChildren(node)[source]

Delete all children of the passed in transform node.

Parameters:node – node whose children we want to delete.
Utilities.utils.exportMesh(mainUI, exportMeshes, exportPath, removeBones, poseDict)[source]

Take the passed in information and export skeletal meshes to FBX format in the specified output path. Invoked from ART_ExportMeshes.py

Parameters:
  • mainUI – instance of rig creator interface. Used to access rig creator class variables
  • exportMeshes – list of meshes to export for the given LOD
  • exportPath – output path of FBX file for the given LOD
  • removeBones – which bones, if any, to remove for the given LOD
  • poseDict – transform values for bones to be applied to given LOD before removing bones, in order to bake in a pose.

Details:

When exporting a LOD skeletal mesh, there are many steps that need to happen:
  • First, the LOD needs to go back to the model pose. If there are any joints this LOD needs to remove, we must save out the skin weight information first.
  • If there is a LOD pose to set, set the pose then while the mesh is still skinned.
  • After setting the LOD pose, search for any connected blendshapes the meshes may have. If there are not true copies of the mesh in the scene, manually create new morph target copies by going through each blendshape attribute turning them on, one by one, duplicating the mesh each time.
  • After checking for blendshapes, delete history on the meshes. This will bake the LOD pose in.
  • Next, re-apply the blendshapes now that the pose is baked in and import the skin weights.
  • If there were bones to remove, before removing the joints, transfer the weighting of those bones to the bone that was specified to transfer weighting to. Usually this is the first valid parent. So if removing all finger bones in an LOD, you would likely transfer all finger weights to the hand bone.
  • Once the weighting is transferred, it is then safe to delete the bones that were to be removed.
  • Now, we start building our selection of things to export. First though, we will check for any incoming connections to our joints that we want to export, and break those connections. These are usually connections to the rig, and we don’t want FBX exporting all of that stuff.
  • Build the selection (joints and morphs) and export FBX
Utilities.utils.findAllSkinnableGeo()[source]

Find all meshes in the scene, list their parents. If the parent is not part of the joint mover (proxy geo, lra representations, or bone representation geo) add it to the list of meshes that can be skinned.

Returns:a list of geometry that is valid for skinning.
Utilities.utils.findAndRenameOutlinerChildren(widgetItem, partitionName, newName)[source]

Find all child widgets of the passed in widgetItem and set their text to the new module name. Usually invoked when a user wants to change the module name.

Parameters:
  • widgetItem – widget to search and replace the names of the children widgets
  • partitionName – the original module name
  • newName – the new module name
Utilities.utils.findAssociatedControl(node)[source]
Utilities.utils.findAssociatedMover(joint, module, useOffset=False)[source]

Find the global mover associated with the passed in joint and the passed in network node. Usually invoked from riggingUtils when creating a control from a joint mover.

Parameters:
  • joint – name of the joint whose associated mover you wish to find.
  • module – name of the module the joint belongs to. Used to figure out if any prefixes or suffixes were used.
Returns:

name of global mover

Utilities.utils.findExportMeshData()[source]

Search through the character node LOD attributes to find out what and how to export the LOD. This data included the LOD pose, the bones to remove, the meshes for the LOD, the output path for the FBX, and the LOD name.

Returns:[output path for FBX, list of meshes to export for LOD, list of bones to remove for LOD, pose to put LOD in before removing bones, the LOD number]
Utilities.utils.findGlobalMoverFromName(name)[source]

Find the top-most global mover of a given module and return it.

Parameters:name – name of the module whose top-most global mover we wish to find.
Returns:name of the global mover of given module name.
Utilities.utils.findMatchingModule(joint)[source]

Look through all network nodes for their created bones attribute and find the network node that contains the input joint

Parameters:joint – joint to find associated network node
Returns:associated network node
Utilities.utils.findModuleInstances(character)[source]
Utilities.utils.findMoverNodeFromJointName(networkNodes, jointName, offsetMover=True, globalMover=False)[source]

Look for the passed in joint name in the Created_Bones attribute of all network nodes in the scene. Once found, find the joint’s associated offset or global mover.

Parameters:
  • networkNodes – list of network nodes to search for jointName in Created_Bones attribute
  • jointName – name of joint whose mover (offset or global) we are trying to find
  • offsetMover – Whether to return the offset mover
  • globalMover – Whether to return the global mover
Returns:

the name of the associated joint mover for the given joint

Utilities.utils.findOffsetMoverFromName(name)[source]

Find the top-most offset mover of a given module and return it.

Parameters:name – name of the module whose top-most offset mover we wish to find.
Returns:name of the offset mover of given module name.
Utilities.utils.find_all_incoming(start_nodes, max_depth=None)[source]

Recursively finds all unique incoming dependencies for the specified node.

Returns:list of dependencies associated with node.
Utilities.utils.find_origin_control()[source]

Finds the control to use as a reflection point for mirroring poses.

Utilities.utils.find_parent_controls(control)[source]

Finds a given control’s parent controls. Not just in terms of direct hierarchy, but any control in the entire rig that influences the given control. For example, the offset_anim and body_anim affect many controls. :param control: :return:

Utilities.utils.fitSelection()[source]

Frame the camera up on the current selection.

Utilities.utils.fitViewAndShade()[source]

Focus the camera on what is in the scene, fitting it to the view, then turn on shaded mode.

Utilities.utils.getFaceMaterials(geo)[source]

Get and return the materials assigned to each face of the passed in geometry.

Utilities.utils.getLodData()[source]

Search the character node for and LOD related attributes and return those.

Returns:list of attributes on character node that contain LOD export data.
Utilities.utils.getMayaPyLoc()[source]

This function finds the location of the mayapy interpreter for batch functions.

Returns:mayapy location
Utilities.utils.getViableParents()[source]

Look for all network nodes in the scene, and search for the Created_Bones attribute, which holds the names of the bones a particular module will create given its current settings. Add all created bones from all modules to a list to be returned.

Returns:list of all the bone names created by the current modules in the scene.
Utilities.utils.get_all_controls(all_characters=True, character_node=None)[source]

Gets all controls of either all characters, or the specified character. :param all_characters: Whether or not to get controls for all characters in the scene. :param character_node: A specific character to get controls for. :return: A list of the controls.

Utilities.utils.get_mobject(name)[source]

Get’s MObject from given name.

Utilities.utils.get_module_types()[source]

Searches the rig modules folder for all the module types

Returns:Returns a list of the module types
Utilities.utils.get_namespace(name)[source]

Gets the namespace from the given name.

Parameters:name – String to extract the namespace from.
Returns:The extracted namespace
Utilities.utils.get_prefix_suffix(name, base_name)[source]

Take the given name and base_name and find the prefix and suffix. :param name: the name of the module (ex: arm_l) :param base_name: the base name of the module (ex: arm) :return:

Utilities.utils.get_traceback(traceback_object, add_locals=True)[source]
Utilities.utils.remove_namespace(name)[source]

Removes the namespace from the given name

Parameters:name – The name with the namespace
Returns:The name without the namesapce
Utilities.utils.returnCharacterModule()[source]

Look for all network nodes in the scene. Return the main network node that all other ART network nodes connect to (also known as the character node)

Returns:character node that stores character information.
Utilities.utils.returnCharacterModules()[source]

Look for all network nodes in the scene. Return all character network nodes found.

Returns:list of character network nodes which list details about the character.
Utilities.utils.returnFriendlyPath(path)[source]

Take the incoming path and replace back slashes with forward slashes

Parameters:path – directory or file path to replace back slashes in
Returns:a directory or file path with only forward slashes
Utilities.utils.returnNicePath(toolsPath, imagePath)[source]

Take the incoming path and file and use os.path.join to create a new file path. Then replace all back slashes with forward slashes.

Parameters:
  • toolsPath – the base directory path
  • imagePath – the file name to join onto the base path
Returns:

a joined path with only forward slashes

Utilities.utils.returnRigModuleTypes()[source]

Look for all network nodes in the scene. Get the moduleType attribute value for any valid nodes and append that to our list of modules to return, giving us a list of all of the types of modules our character has.

Returns:list of the different types of modules in our scene (ART_Arm, ART_Leg, etc)
Utilities.utils.returnRigModules()[source]

Look for all network nodes in the scene. Return network nodes that have a .parent attribute.

Returns:list of network nodes that have .parent attr, signifying an ART network node
Utilities.utils.returnTooltipPath(path)[source]
Utilities.utils.return_module_instances()[source]
Utilities.utils.splitMesh(mesh, assetName)[source]

Take the given mesh and break it into chunks based on the influence weights of each bone. For example, if the mesh was a leg that was skinned to a thigh bone, a calf bone, and a foot bone, this function will split the leg mesh into three new meshes, one for each major influence. This is sometimes known as an “anim mesh”

Parameters:
  • mesh – name of mesh to split up
  • assetName – name of character or rig (the name given on publish)
Returns:

a list of the newly created meshes

Utilities.utils.win_path_convert(path=None)[source]

Converts back slashes to forward slashes

Utilities.utils.xrayJoints()[source]

Gets the current model editor and turns on xray joints