General Utilities

Code author: Jeremy Ernst

This module provides utilities usually for returning information, handling paths, or building strings.

Functions

convert_to_pynodes(nodes)[source]

Converts the incoming nodes to PyNodes and returns them.

Parameters:nodes – String list of nodes to convert.
Returns:List of PyNodes
create_asset(asset_name)[source]

Create a container asset with the given asset name and return the created container. :param asset_name: Name for container. :return: pyNode of created asset.

filter_nodes(nodes, filter_by='transform')[source]

Filters the given nodes by the given type and returns the filtered nodes as a list. :param nodes: List of nodes to filter. :param str filter_by: Types of nodes to return. :return: List of filtered nodes.

get_joints_in_hierarchy(root=None, as_pynode=False)[source]

Gets the joints in a hierarchy and returns them. If a root joint is given, it will search from there. If not, it will select everything in the scene and find the joints that way instead. :param root: (Optional) Name of joint at the top of the hierarchy you wish to search. :param as_pynode: Bool as whether to return the list as PyNodes or strings. :return: Returns either a list of PyNodes or strings of the joints in the hierarchy.

get_root_joint_of_component(joints)[source]

Finds and returns the top-most joint of a component.

Parameters:joints – List of Pynodes of joints from the component.
Returns:Pynode of top-most joint.
import_file(path, return_nodes=False)[source]

Imports the given file into Maya. :param path: Path of file to import :param return_nodes: Whether or not to return created nodes. :return: list of imported nodes

parent_object(child, parent)[source]

Parents the child to the parent object.

Parameters:
  • child (str) – Name of node to be parented.
  • parent (str) – Name of node that will be the parent.
path_join(path_base, path_tail)[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:
  • path_base (str) – First part of path to join.
  • path_tail (str) – Second part of path to join.
Returns:

Joined path with proper separators.

Return type:

str

path_unify(path)[source]

Take the incoming path and replace back slashes with forward slashes.

Parameters:path (str) – Incoming path to manipulate.
Returns:Corrected path with correct separators.
Return type:str
rename_object(pynode, new_name)[source]

Renames the incoming PyNode with the given new name.

Parameters:
  • pynode (pymel.core.PyNode) – PyNode that represents the object to rename.
  • new_name (str) – The new name for the node.
return_settings()[source]

Returns ARTv2 settings for the paths to various needed directories.

Returns:Array of path names to directories needed by the tools.
Return type:str, []
set_attribute(node, attr, value, attr_type=None)[source]

Sets an attribute on the given node to the given value. Ensures node and attribute is unlocked before doing so, and re-locks them after.

Parameters:
  • node (pm.PyNode) – Node to set attribute on.
  • attr (str) – Attribute on node to set.
  • value (float, int, bool, string) – Value to set attribute to.
  • attr_type (str) – Whether or not a special type needs to be defined (string, bool, etc)
strip_name(name_to_strip, prefix, base_name, suffix)[source]

Strip a name down to whatever is left after removing the prefix, base name, and suffix.

Parameters:
  • name_to_strip (str) – The name to tokenize.
  • prefix (str) – The prefix to remove from the name.
  • base_name (str, None) – The base name of the component to remove from the name.
  • suffix (str) – The suffix to remove from the name.
Returns:

The name with the prefix, suffix, and base name removed.

Return type:

str