vtool.maya_lib.space

Class Summary

VertexOctree()

VertexOctreeNode(boundingBoxData)

PinXform(xform_name)

This allows you to pin a transform so that its parent and child are not affected by any edits.

MatchSpace(source_transform, target_transform)

Used to match transformation between two transform node.

ConstraintEditor()

Convenience class for editing constraints.

IkHandle(name)

Convenience for creating ik handles.

OrientJoint(joint_name[, children])

This will orient the joint using the attributes created with OrientJointAttributes.

BoundingBox(thing[, ignore_invisible])

Convenience for dealing with bounding boxes.

AttachJoints(source_joints, target_joints)

Attach a chain of joints to a matching chain.

DuplicateHierarchy(transform)

Duplicate the hierachy of a transform.

BuildHierarchy()

OverDriveTranslation(transform, driver)

TranslateSpaceScale()

MatrixConstraintNodes(source_transform[, ...])

MatrixConstraint(source_transform[, ...])

SpaceSwitch([sources, target])

SpaceSwitchPairBlend(source1, source2, target)

Function Summary

has_constraint(transform)

Find out if a constraint is affecting the transform.

delete_constraints(transform[, constraint_type])

Delete constraints on transform.

is_transform_default(transform)

Check if a transform has the default values (identity matrix).

is_rotate_default(transform)

is_rotate_scale_default(transform)

get_non_default_transforms([transforms])

Get transforms in the scene that don't have default values.

zero_out_transform_channels(transform)

Zero out the translate and rotate on a transform.

zero_out_pivot(transform)

get_hierarchy_path(top_transform, btm_transform)

Gets relatives in the hierarchy between top_transform and btm_transform

get_bounding_box_size(transform)

Get the size of the bounding box.

get_center(transform)

Get the center of a selection.

get_btm_center(transform)

Get the bottom center of a selection.

get_top_center(transform)

Get the top center of a selection.

get_longest_aligned_vectors(transform)

When auto placing joints, this can help allign them to the mesh.

get_closest_transform(source_transform, targets)

Given the list of target transforms, find the closest to the source transform.

get_middle_transform(transform_list)

Given a list of transforms, find the middle index.

get_distance(source, target)

Get the distance between the source transform and the target transform.

get_chain_length(list_of_joints_in_chain)

get_midpoint(source, target)

Get the midpoint between the source transform and the target transform.

get_distances(sources, target)

Given a list of source transforms, return a list of distances to the target transform

get_polevector(transform1, transform2, ...)

Given 3 transforms eg.

get_group_in_plane(transform1, transform2, ...)

Create a group that sits in the triangle plane defined by the 3 transforms.

get_ordered_distance_and_transform(...)

Return a list of distances based on how far each transform in transform list is from source_transform.

get_transform_list_from_distance(...)

Return a list of distances that corresponds to the transform_list.

get_side(transform, center_tolerance)

Get the side of a transform based on its position in world space.

get_axis_vector(transform, axis_vector)

This currently only works on transforms that have not been frozen.

get_axis_aimed_at_child(transform)

get_axis_letter_aimed_at_child(transform)

get_vector_axis_letter(vector)

get_ik_from_joint(joint)

create_follow_fade(source_guide, drivers[, ...])

Create a multiply divide for each transform in drivers with a weight value based on the distance from source_guide.

create_match_group(transform[, prefix, ...])

Create a group that matches a transform.

create_xform_group(transform[, prefix, ...])

Create a group above a transform that matches transformation of the transform.

create_follow_group(source_transform, ...[, ...])

Create a group above a target_transform that is constrained to the source_transform.

create_local_follow_group(source_transform, ...)

Create a group above a target_transform that is local constrained to the source_transform.

create_multi_follow_direct(source_list, ...)

Create a group above the target that is constrained to multiple transforms.

create_multi_follow(source_list, ...[, ...])

Create a group above the target that is constrained to multiple transforms.

create_ghost_follow_chain(transforms)

create_ghost_chain(transforms)

A ghost chain has the same hierarchy has the supplied transforms.

create_pivot_group(source_transform, ...[, ...])

Create a group with pivot at source_tranform above target_transform

create_no_twist_aim(source_transform, ...[, ...])

Aim target transform at the source transform, trying to rotate only on one axis.

create_pole_chain(top_transform, ...[, solver])

Create a two joint chain with an ik handle.

create_ik_on_joint(joint, name[, solver])

get_xform_group(transform[, xform_group_prefix])

This returns an xform group above the control.

get_local_group(transform)

get_hierarchy(node_name)

Return the name of the node including the hierarchy in the name using "|".

has_parent(transform, parent)

Check to see if the transform has parent in its parent hierarchy.

transfer_relatives(source_node, target_node)

Reparent the children of source_node under target_node.

constrain_local(source_transform, ...[, ...])

Constrain a target transform to a source transform in a way that allows for setups to remain local to the origin.

subdivide_joint([joint1, joint2, count, ...])

Add evenly spaced joints inbetween joint1 and joint2.

orient_attributes([scope, ...])

Orient all transforms with attributes added by add_orient_attributes.

orient_attributes_all()

Orient all transforms with attributes added by add_orient_attributes.

auto_generate_orient_attributes(joint[, ...])

get_orient_attribute_default_alignment([...])

get_alt_forward_alignment([forward_axis, ...])

mirror_orient_attributes()

add_orient_joint(joint)

Add orient joint.

orient_x_to_child_up_to_surface(joint[, ...])

orient_x_to_child(joint[, invert, neg_aim])

Helper function to quickly orient a joint to its child.

orient_y_to_child(joint[, invert, neg_aim, ...])

Helper function to quickly orient a joint to its child.

orient_z_to_child(joint[, invert, neg_aim])

Helper function to quickly orient a joint to its child.

find_transform_right_side(transform[, ...])

Try to find the right side of a transform.

find_transform_left_side(transform[, ...])

Try to find the right side of a transform.

mirror_toggle(transform, bool_value)

mirror_xform([prefix, suffix, ...])

Mirror the positions of all transforms that match the search strings.

mirror_invert(transform[, other])

If transform is joint_lip_L and there is a corresponding joint_lip_R, this will change joint_lip_R to have space that mirrors joint_lip_L.

match_all_transform_values(source_transform, ...)

Match transform values from source to target.

match_joint_xform(prefix, other_prefix)

Match the positions of joints with similar names.

match_orient(prefix, other_prefix)

Match the orientations of joints with similar names.

scale_constraint_to_local(scale_constraint)

Scale constraint can work wrong when given the parent matrix.

scale_constraint_to_world(scale_constraint)

Works with scale_constraint_to_local.

duplicate_joint_section(joint[, name])

Joint chains ususally have a parent and a child along the chain.

transforms_to_joint_chain(transforms[, name])

Given a list of transforms, create a joint chain.

positions_to_joint_chain(positions[, name])

param positions

List of vectors. [[0,0,0],[0,0,0],...]

attach_to_closest_transform(...)

Attach the source_transform to the closest transform in the list of target_transforms.

set_space_scale(scale_x, scale_y, scale_z, ...)

connect_inverse_scale(transform, joint)

randomize([translate, rotate, scale, transforms])

Good for giving subtle randomness to many transforms.

fix_locator_shape_position(locator_name)

set_translateX_limit(transform[, min_value, ...])

set_translateY_limit(transform[, min_value, ...])

set_translateZ_limit(transform[, min_value, ...])

set_rotateX_limit(transform[, min_value, ...])

set_rotateY_limit(transform, min_value, ...)

set_rotateZ_limit(transform, min_value, ...)

orig_matrix_match(transform, ...)

This command is to be used for space switching.

class VertexOctree
create(mesh)
add_vertex(vertex_name, vertex_position)
class VertexOctreeNode(boundingBoxData)
create_cube()
subdivide()
set_parent(parent_octree)
get_verts()
add_vertex(vertex_name, vertex_position)
has_verts()
vert_count()
has_children()
find_closest_child(three_number_list)
find_closest_vertex(three_number_list)
sort_mesh_vertex()
class PinXform(xform_name)

This allows you to pin a transform so that its parent and child are not affected by any edits.

pin(children=None)

Create the pin constraints on parent and children.

unpin()

Remove the pin. This should be run after pin.

get_pin_nodes()
Returns

List of nodes involved in the pinning. Ususally includes constraints and empty groups.

Return type

list

class MatchSpace(source_transform, target_transform)

Used to match transformation between two transform node. Can be used as follows: MatchSpace(‘transform1’, ‘transform2’).translation_rotation()

Parameters
  • source_transform (str) – The name of a transform.

  • target_transform (str) – The name of a transform.

translation()

Match just the translation

rotation()

Match just the rotation

translation_rotation()

Match translation and rotation.

translation_to_rotate_pivot()

Match translation of target to the rotate_pivot of source.

rotate_scale_pivot_to_translation()

Match the rotate and scale pivot of target to the translation of source.

pivots()

Match the pivots of target to the source.

world_pivots()

Like pivots, but match in world space.

scale()
class ConstraintEditor

Convenience class for editing constraints.

constraint_parent = 'parentConstraint'
constraint_point = 'pointConstraint'
constraint_orient = 'orientConstraint'
constraint_scale = 'scaleConstraint'
constraint_aim = 'aimConstraint'
editable_constraints = ['parentConstraint', 'pointConstraint', 'orientConstraint', 'scaleConstraint', 'aimConstraint']
has_constraint(transform)
get_weight_names(constraint)
get_weight_count(constraint)

Get the number of inputs weights (transforms) feeding int the constraint.

Parameters

constraint (str) – The name of a constraint.

get_constraint(transform, constraint_type)

Find a constraint on the transform.

Parameters
  • transform (str) – The name of a transform that is constrained.

  • constraint_type (str) – The type of constraint to search for. Eg. parentConstraint, orientConstraint, pointConstraint, etc.

Retrun

str: The name of the constraint.

get_transform(constraint)

Get the transform that the constraint is constraining.

Parameters

constraint (str) – The name of the constraint.

Returns

The name of the transform that is being constrained.

Return type

str

get_targets(constraint)

Get the transforms influencing the constraint.

Parameters

constraint (str) – The name of the constraint.

Returns

The names of the transforms affecting the constraint.

Return type

list

remove_target(target, constraint)

Remove a target from a constraint. This only works if the constraint has all its original connections intact.

Parameters
  • target (str) – The name of the transform target to remove.

  • constraint (str) – The name of a constraint that has target affecting it.

set_interpolation(int_value, constraint)

Set the interpolation type of the constraint.

Parameters
  • int_value (int) – index of the interpolation type.

  • constraint (str) – The name of a constraint. Probably “parentConstraint” or “orientConstraint”.

set_auto_use_last_number(bool_value)
create_title(node, constraint, title_name='FOLLOW')

This will create a title enum attribute based on the targets feeding into a constraint. The enum will have the name of the transforms affecting the constraint.

Parameters
  • node (str) – The name of the node to add the title to.

  • constraint (str) – The name of a constraint. Should be affected by multipe transforms.

  • title_name (str) – The name to give the title attribute.

create_switch(node, attribute, constraint)

Create a switch over all the target weights.

Parameters
  • node (str) – The name of the node to add the switch attribute to.

  • attribute (str) – The name to give the switch attribute.

  • constraint (str) – The name of the constraint with multiple weight target transforms affecting it.

delete_constraints(transform, constraint_type='None')
class IkHandle(name)

Convenience for creating ik handles.

Parameters

name (str) – The description to give the node. Name = ‘ikHandle_(name)’.

solver_rp = 'ikRPsolver'
solver_sc = 'ikSCsolver'
solver_spline = 'ikSplineSolver'
solver_spring = 'ikSpringSolver'
set_start_joint(joint)

Set start joint for the ik handle.

Parameters

joint (str) – The name of the start joint.

set_end_joint(joint)

Set end joint for the ik handle.

Parameters

joint (str) – The name of the end joint.

set_joints(joints_list)

Set the joints for the ik handle. start joint becomes the first entry. end joint beomces the las entry.

Parameters

joints_list (list) – A list of joints.

set_curve(curve)

Set the curve for spline ik.

Parameters

curve (str) – The name of the curve.

set_solver(type_name)

Set the solver type.

solver types: ‘ikRPsolver’ ‘ikSCsolver’ ‘ikSplineSolver’ ‘ikSpringSolver’

Parameters

type_name (str) – The name of the solver type.

set_full_name(fullname)

Set the full name for the ik handle, no prefixing or formatting added.

create()

Create the ik handle.

Returns

The name of the ik handle.

Return type

str

class OrientJoint(joint_name, children=[])

This will orient the joint using the attributes created with OrientJointAttributes.

set_aim_vector(vector_list)
Parameters
  • vector_list (list) – [0,0,0] vector that defines what axis should aim.

  • [1 (If joint should aim with X axis then vector should be) –

  • 0

  • [0 (0]. If joint should aim with Y axis then) –

  • 1

  • 0]

  • etc.

  • [-1 (If up needs to be opposite of X axis then vector should be) –

  • 0

  • 0].

set_up_vector(vector_list)
Parameters
  • vector_list (list) – [0,0,0] vector that defines what axis should aim up.

  • [1 (If joint should aim up with X axis then vector should be) –

  • 0

  • [0 (0]. If joint should aim up with Y axis then) –

  • 1

  • 0]

  • etc.

  • [-1 (If up needs to be opposite of X axis then vector should be) –

  • 0

  • 0].

set_world_up_vector(vector_list)
Parameters
  • vector_list (list) – [0,0,0] vector that defines what world up axis be.

  • [1 (If world should aim up with X axis then vector should be) –

  • 0

  • [0 (0]. If world should aim up with Y axis then) –

  • 1

  • 0]

  • etc.

  • [-1 (If up needs to be opposite of X axis then vector should be) –

  • 0

  • 0].

set_aim_at(int_value)

Set how the joint aims.

Parameters

int_value (int) – 0 aim at world X, 1 aim at world Y, 2 aim at world Z, 3 aim at immediate child. 4 aim at immediate parent. 5 aim at local parent, which is like aiming at the parent and then reversing direction.

set_aim_up_at(int_value)

Set how the joint aims up.

Parameters

int_value (int) – 0 world, 1 parent rotate, 2 child position, 3 parent position, 4 triangle plane, which need to be configured to see which joints in the hierarchy it calculates with. 5 child 2 6 surface

set_surface(surface_name)
set_aim_up_at_object(name)
set_invert_scale(axis_letters)
run()
class BoundingBox(thing, ignore_invisible=False)

Convenience for dealing with bounding boxes.

Parameters

thing (str) – The name of a transform in maya. Bounding box info is automatically loaded from the transform.

get_center()

Get the center of the bounding box in a vector.

Returns

[0,0,0] vector

Return type

list

get_longest_two_axis_vectors()

get the two longest vectors of a single axis This can help when automatically placing joints

get_size()
get_size_no_y()
get_xmax_center()
get_xmin_center()
get_ymax_center()

Get the top center of the bounding box in a vector.

Returns

[0,0,0] vector

Return type

list

get_ymin_center()

Get the btm center of the bounding box in a vector.

Returns

[0,0,0] vector

Return type

list

get_zmax_center()
get_zmin_center()
class AttachJoints(source_joints, target_joints)

Attach a chain of joints to a matching chain. parentConstraint and scaleConstraint are used to make the attachment.

attach_type_constraint = 0
attach_type_matrix = 1
set_source_and_target_joints(source_joints, target_joints)
Parameters
  • source_joints (list) – A list of joint names that should move the target.

  • target_joints (list) – A list of joints names that should be moved by the source.

set_attach_type(attach_type)
create()

Create the attachments.

class DuplicateHierarchy(transform)

Duplicate the hierachy of a transform.

Parameters

transform (str) – The name of a transform with child hierarchy.

only_these(list_of_transforms)

Only duplicate transforms in list_of_transforms.

Parameters

list_of_transforms (list) – Names of transforms in the hierarchy.

only_joints(bool_value)
stop_at(transform)

The transform at which to stop the duplication.

Parameters

transform (str) – The name of the transform.

add_prefix(prefix)
add_suffix(suffix)
replace(old, new)

Replace the naming in the duplicate.

Parameters
  • old (str) – String in the duplicate name to replace.

  • new (str) – String in the duplicate to replace with.

remove_user_attrs_on_duplicate(bool_value)
create()

Create the duplicate hierarchy.

class BuildHierarchy
set_transforms(transform_list)
set_replace(old, new)
create()
class OverDriveTranslation(transform, driver)
set_x(positive_x, negative_x)
set_y(positive_y, negative_y)
set_z(positive_z, negative_z)
create()
class TranslateSpaceScale
set_x_space(positive_distance, negative_distance)
set_y_space(positive_distance, negative_distance)
set_z_space(positive_distance, negative_distance)
set_source_translate(source)
set_target_scale(target)
create()
class MatrixConstraintNodes(source_transform, target_transform=None)
set_description(description)
set_decompose(bool_value)
set_connect_translate(bool_value)
set_connect_rotate(bool_value)
set_connect_scale(bool_value)
create()
class MatrixConstraint(source_transform, target_transform=None)
set_use_target_parent_matrix(bool_value)
set_maintain_offset(bool_value)
create()
set_connect_rotate(bool_value)
set_connect_scale(bool_value)
set_connect_translate(bool_value)
set_decompose(bool_value)
set_description(description)
class SpaceSwitch(sources=[], target=None)
get_space_switches(target)
get_source(switch_node)
add_source(source_transform, target_transform, switch_node)
set_use_weight(bool_value)
set_input_attribute(node, attribute, switch_names=[])
set_maintain_offset(bool_value)
create_title(bool_value, title_name=None)
create(create_switch=False)
create_switch(node, attribute, switch_node=None)

Create a switch over all the target weights.

Parameters
  • node (str) – The name of the node to add the switch attribute to.

  • attribute (str) – The name to give the switch attribute.

  • switch_node (str) – Either the choice or wtAddMatrix node of the setup. Use get_space_switches to find them

set_connect_rotate(bool_value)
set_connect_scale(bool_value)
set_connect_translate(bool_value)
set_decompose(bool_value)
set_description(description)
class SpaceSwitchPairBlend(source1, source2, target)
connect_linear(attribute_name)
connect_pair_blend()
set_description(description)
set_attribute_control(node, attribute_name)
create()
has_constraint(transform)

Find out if a constraint is affecting the transform.

Parameters

transform (str) – The name of a transform.

delete_constraints(transform, constraint_type=None)

Delete constraints on transform.

is_transform_default(transform)

Check if a transform has the default values (identity matrix).

For example:

transate = [0,0,0]

rotate = [0,0,0]

scale = [1,1,1]

Returns

bool

is_rotate_default(transform)
is_rotate_scale_default(transform)
get_non_default_transforms(transforms=None)

Get transforms in the scene that don’t have default values.

Returns

list

zero_out_transform_channels(transform)

Zero out the translate and rotate on a transform.

zero_out_pivot(transform)
get_hierarchy_path(top_transform, btm_transform)

Gets relatives in the hierarchy between top_transform and btm_transform

Parameters
  • top_transform (str) – The name of the top transform.

  • btm_transform (str) – The name of the btm transform. Needs to be a child of top_transform.

get_bounding_box_size(transform)

Get the size of the bounding box.

Returns

float

get_center(transform)

Get the center of a selection. Selection can be component or transform.

Parameters

transform (str) – Name of a node in maya.

Returns

The center vector, eg [0,0,0]

Return type

vector list

get_btm_center(transform)

Get the bottom center of a selection. Selection can be component or transform.

Parameters

transform (str) – Name of a node in maya.

Returns

The btrm center vector, eg [0,0,0]

Return type

vector list

get_top_center(transform)

Get the top center of a selection. Selection can be component or transform.

Parameters

transform (str) – Name of a node in maya.

Returns

The top center vector, eg [0,0,0]

Return type

vector list

get_longest_aligned_vectors(transform)

When auto placing joints, this can help allign them to the mesh. If the model is not square it, the two vectors will be aligned to longest length of the model.

get_closest_transform(source_transform, targets)

Given the list of target transforms, find the closest to the source transform.

Parameters
  • source_transform (str) – The name of the transform to test distance to.

  • targets (list) – List of targets to test distance against.

Returns

The name of the target in targets that is closest to source_transform.

Return type

str

get_middle_transform(transform_list)

Given a list of transforms, find the middle index. If the list is even, then find the midpoint between the middle two indices.

Parameters

transform_list (list) – A list of transforms in order. Transforms should make a hierarchy or a sequence, where the order of the list matches the order in space.

Returns

[x,y,z] the midpoint.

Return type

list

get_distance(source, target)

Get the distance between the source transform and the target transform.

Parameters
  • source (str) – The name of a transform.

  • target (str) – The name of a transform.

Returns

The distance between source and target transform.

Return type

float

get_chain_length(list_of_joints_in_chain)
get_midpoint(source, target)

Get the midpoint between the source transform and the target transform.

Parameters
  • source (str) – The name of a transform.

  • target (str) – The name of a transform.

Returns

The midpoint as [0,0,0] vector between source and target transform.

Return type

vector list

get_distances(sources, target)

Given a list of source transforms, return a list of distances to the target transform

Parameters
  • sources (list) – The names of a transforms.

  • target (str) – The name of a transform.

Returns

The distances betweeen each source and the target.

Return type

list

get_polevector(transform1, transform2, transform3, offset=1)

Given 3 transforms eg. arm, elbow, wrist. Return a vector of where the pole vector should be located.

Parameters
  • transform1 (str) – name of a transform in maya. eg. joint_arm.

  • transform2 (str) – name of a transform in maya. eg. joint_elbow.

  • transform3 (str) – name of a transform in maya. eg. joint_wrist.

Returns

The triangle plane vector eg. [0,0,0]. This is good for placing the pole vector.

Return type

vector list

get_group_in_plane(transform1, transform2, transform3)

Create a group that sits in the triangle plane defined by the 3 transforms.

Parameters
  • transform1 (str) – name of a transform in maya. eg. joint_arm.

  • transform2 (str) – name of a transform in maya. eg. joint_elbow.

  • transform3 (str) – name of a transform in maya. eg. joint_wrist.

Returns

The triangle plane vector eg. [0,0,0]. This is good for placing the pole vector.

Return type

vector list

get_ordered_distance_and_transform(source_transform, transform_list)

Return a list of distances based on how far each transform in transform list is from source_transform. Return a distance dictionary with each distacne key returning the corresponding transform. Return a list with the original distance order has fed in from transform_list.

Parameters
  • source_transform (str) –

  • transform_list (list) –

Returns

dict

get_transform_list_from_distance(source_transform, transform_list)

Return a list of distances that corresponds to the transform_list. Each transform’s distance from source_transform.

get_side(transform, center_tolerance)

Get the side of a transform based on its position in world space. Center tolerance is distance from the center to include as a center transform.

Parameters
  • transform (str) – The name of a transform.

  • center_tolerance (float) – How close to the center the transform must be before it is considered in the center.

Returns

The side that the transform is on, could be ‘L’,’R’ or ‘C’.

Return type

str

get_axis_vector(transform, axis_vector)

This currently only works on transforms that have not been frozen. It does not work on joints.

Get the vector matrix product. If you give it a vector [1,0,0], it will return the transform’s x point. If you give it a vector [0,1,0], it will return the transform’s y point. If you give it a vector [0,0,1], it will return the transform’s z point.

Parameters
  • transform (str) – The name of a transform. Its matrix will be checked.

  • axis_vector (list) – A vector. X = [1,0,0], Y = [0,1,0], Z = [0,0,1]

Returns

The result of multiplying the vector by the matrix. Good to get an axis in relation to the matrix.

Return type

list

get_axis_aimed_at_child(transform)
get_axis_letter_aimed_at_child(transform)
get_vector_axis_letter(vector)
get_ik_from_joint(joint)
create_follow_fade(source_guide, drivers, skip_lower=0.0001)

Create a multiply divide for each transform in drivers with a weight value based on the distance from source_guide.

Parameters
  • source_guide (str) – Name of a transform in maya to calculate distance.

  • drivers (list) – List of drivers to apply fade to based on distance from source_guide.

  • skip_lower (float) – The distance below which multiplyDivide fading stops.

Returns

The list of multiplyDivide nodes.

Return type

list

create_match_group(transform, prefix='match', use_duplicate=False)

Create a group that matches a transform. Naming = ‘match_’ + transform

Parameters
  • transform (str) – The transform to match.

  • prefix (str) – The prefix to add to the matching group.

  • use_duplicate (bool) – If True, matching happens by duplication instead of changing transform values.

Returns

The name of the new group.

Return type

str

create_xform_group(transform, prefix='xform', use_duplicate=False, copy_scale=False)

Create a group above a transform that matches transformation of the transform. This is good for zeroing out the values of a transform. Naming = ‘xform_’ + transform

Parameters
  • transform (str) – The transform to match.

  • prefix (str) – The prefix to add to the matching group.

  • use_duplicate (bool) – If True, matching happens by duplication instead of changing transform values.

Returns

The name of the new group.

Return type

str

create_follow_group(source_transform, target_transform, prefix='follow', follow_scale=False, use_duplicate=False)

Create a group above a target_transform that is constrained to the source_transform.

Parameters
  • source_transform (str) – The transform to follow.

  • target_transform (str) – The transform to make follow.

  • prefix (str) – The prefix to add to the follow group.

  • follow_scale (bool) – Wether to add a scale constraint or not.

Returns

The name of the new group.

Return type

str

create_local_follow_group(source_transform, target_transform, prefix='followLocal', orient_only=False, connect_scale=False)

Create a group above a target_transform that is local constrained to the source_transform. This helps when setting up controls that need to be parented but only affect what they constrain when the actual control is moved.

Parameters
  • source_transform (str) – The transform to follow.

  • target_transform (str) – The transform to make follow.

  • prefix (str) – The prefix to add to the follow group.

  • orient_only (bool) – Wether the local constraint should just be an orient constraint.

Returns

The name of the new group.

Return type

str

create_multi_follow_direct(source_list, target_transform, node, constraint_type='parentConstraint', attribute_name='follow', value=None)

Create a group above the target that is constrained to multiple transforms. A switch attribute switches their state on/off. Direct in this case means the constraints will be added directly on the target_transform.

Parameters
  • source_list (list) – List of transforms that the target should be constrained by.

  • target_transform (str) – The name of a transform that should follow the transforms in source list.

  • node (str) – The name of the node to add the switch attribute to.

  • constraint_type (str) – Corresponds to maya’s constraint types. Currently supported: parentConstraint, pointConstraint, orientConstraint.

  • attribute_name (str) – The name of the switch attribute to add to the node.

  • value (float) – The value to give the switch attribute on the node.

Returns

The name of the new group.

Return type

str

create_multi_follow(source_list, target_transform, node=None, constraint_type='parentConstraint', attribute_name='follow', value=None, create_title=True)

Create a group above the target that is constrained to multiple transforms. A switch attribute switches their state on/off. Direct in this case means the constraints will be added directly on the target_transform.

Parameters
  • source_list (list) – List of transforms that the target should be constrained by.

  • target_transform (str) – The name of a transform that should follow the transforms in source list.

  • node (str) – The name of the node to add the switch attribute to.

  • constraint_type (str) – Corresponds to maya’s constraint types. Currently supported: parentConstraint, pointConstraint, orientConstraint.

  • attribute_name (str) – The name of the switch attribute to add to the node.

  • value (float) – The value to give the switch attribute on the node.

Returns

The name of the new group.

Return type

str

create_ghost_follow_chain(transforms)
create_ghost_chain(transforms)

A ghost chain has the same hierarchy has the supplied transforms. It connects into the an xform group above the transform. This allows for setups that follow a nurbs surface, and then work like an fk hierarchy after.

Parameters

transforms (list) – A list of transforms.

Returns

A list of ghost transforms corresponding to transforms.

Return type

list

create_pivot_group(source_transform, target_transform, prefix='pivot', match_pivot_position_only=True)

Create a group with pivot at source_tranform above target_transform

create_no_twist_aim(source_transform, target_transform, parent, move_vector=[0, 0, 1])

Aim target transform at the source transform, trying to rotate only on one axis. Constrains the target_transform.

Parameters
  • source_transform (str) – The name of a transform.

  • target_transform (str) – The name of a transform.

  • parent (str) – The parent for the setup.

create_pole_chain(top_transform, btm_transform, name, solver='ikSCsolver')

Create a two joint chain with an ik handle.

Parameters
  • top_transform (str) – The name of a transform.

  • btm_transform (str) – The name of a transform.

  • name (str) – The name to give the new joints.

Returns

(joint1, joint2, ik_pole)

Return type

tuple

create_ik_on_joint(joint, name, solver='ikSCsolver')
get_xform_group(transform, xform_group_prefix='xform')

This returns an xform group above the control.

Parameters

name (str) – The prefix name supplied when creating the xform group. Usually xform or driver.

get_local_group(transform)
get_hierarchy(node_name)

Return the name of the node including the hierarchy in the name using “|”. This is the full path of the node.

Parameters

node_name (str) – A node name.

Returns

The node name with hierarchy included. The full path to the node.

Return type

str

has_parent(transform, parent)

Check to see if the transform has parent in its parent hierarchy.

Parameters
  • transform (str) – The name of a transform.

  • parent (str) – The name of a parent transform.

Returns

bool

transfer_relatives(source_node, target_node, reparent=False)

Reparent the children of source_node under target_node. If reparent, move the target_node under the parent of the source_node.

Parameters
  • source_node (str) – The name of a transform to take relatives from.

  • target_node (str) – The name of a transform to transfer relatives to.

  • reparent (bool) – Wether to reparent target_node under source_node after transfering relatives.

constrain_local(source_transform, target_transform, parent=False, scale_connect=False, constraint='parentConstraint', use_duplicate=False)

Constrain a target transform to a source transform in a way that allows for setups to remain local to the origin. This is good when a control needs to move with the rig, but move something at the origin only when the actually control moves.

Parameters
  • source_transform (str) – The name of a transform.

  • target_transform (str) – The name of a transform.

  • parent (bool) – The setup uses a local group to constrain the target_transform. If this is true it will parent the target_transform under the local group.

  • scale_connect (bool) – Wether to also add a scale constraint.

  • constraint (str) – The type of constraint to use. Currently supported: parentConstraint, pointConstraint, orientConstraint.

Returns

The local group that constrains the target_transform, and the xform group above the local group.

Return type

(str, str)

subdivide_joint(joint1=None, joint2=None, count=1, prefix='joint', name='sub_1', duplicate=False)

Add evenly spaced joints inbetween joint1 and joint2.

Parameters
  • joint1 (str) – The first joint. If None given, the first selected joint.

  • joint2 (str) – The second joint. If None given, the second selected joint.

  • count (int) – The number of joints to add inbetween joint1 and joint2.

  • prefix (str) – The prefix to add in front of the new joints.

  • name (str) – The name to give the new joints after the prefix. Name = prefix + ‘_’ + name

  • duplicate (bool) – Wether to create a duplicate chain.

Returns

List of the newly created joints.

Return type

list

orient_attributes(scope=None, initialize_progress=True, hierarchy=True)

Orient all transforms with attributes added by add_orient_attributes. If scope is provided, only orient transforms in the scope that have attributes.

Parameters

scope (list) – List of transforms to orient.

orient_attributes_all()

Orient all transforms with attributes added by add_orient_attributes. If scope is provided, only orient transforms in the scope that have attributes.

Parameters

scope (list) – List of transforms to orient.

auto_generate_orient_attributes(joint, align_forward='Z', align_up='Y')
get_orient_attribute_default_alignment(forward_axis='Z', up_axis='Y')
get_alt_forward_alignment(forward_axis='Z', up_axis='Y')
mirror_orient_attributes()
add_orient_joint(joint)

Add orient joint. This will create an up and an aim joint.

Parameters

joint (str) – The name of the joint to add the up and the aim to.

orient_x_to_child_up_to_surface(joint, invert=False, surface=None, neg_aim=False)
orient_x_to_child(joint, invert=False, neg_aim=False)

Helper function to quickly orient a joint to its child.

Parameters
  • joint (str) – The name of the joint to orient. Must have a child.

  • invert (bool) – Wether to mirror the orient for right side.

orient_y_to_child(joint, invert=False, neg_aim=False, up_axis=[0, 0, 1])

Helper function to quickly orient a joint to its child.

Parameters
  • joint (str) – The name of the joint to orient. Must have a child.

  • invert (bool) – Wether to mirror the orient for right side.

orient_z_to_child(joint, invert=False, neg_aim=False)

Helper function to quickly orient a joint to its child.

Parameters
  • joint (str) – The name of the joint to orient. Must have a child.

  • invert (bool) – Wether to mirror the orient for right side.

find_transform_right_side(transform, check_if_exists=True)

Try to find the right side of a transform. _L will be converted to *_R if not L_ will be converted to R_* if not lf_ will be converted to rt_

Parameters

transform (str) – The name of a transform.

Returns

The name of the right side transform if it exists.

Return type

str

find_transform_left_side(transform, check_if_exists=True)

Try to find the right side of a transform. _R will be converted to *_L if not R_ will be converted to L_* if not rt_ will be converted to lf_

Parameters

transform (str) – The name of a transform.

Returns

The name of the right side transform if it exists.

Return type

str

mirror_toggle(transform, bool_value)
mirror_xform(prefix=None, suffix=None, string_search=None, create_if_missing=False, transforms=[], left_to_right=True, skip_meshes=True)

Mirror the positions of all transforms that match the search strings. If search strings left at None, search all transforms and joints.

Parameters
  • prefix (str) – The prefix to search for.

  • suffix (str) – The suffix to search for.

  • string_search (str) – Search for a name containing string search.

mirror_invert(transform, other=None)

If transform is joint_lip_L and there is a corresponding joint_lip_R, this will change joint_lip_R to have space that mirrors joint_lip_L.

match_all_transform_values(source_transform, target_transform)

Match transform values from source to target.

match_joint_xform(prefix, other_prefix)

Match the positions of joints with similar names. For example, skin_arm_L could be matched to joint_arm_L, if they exists and prefix = skin and other_prefix = joint. :param prefix: :type prefix: str :param other_prefix: :type other_prefix: str

match_orient(prefix, other_prefix)

Match the orientations of joints with similar names. For example, skin_arm_L could be matched to joint_arm_L, if they exists and prefix = skin and other_prefix = joint. :param prefix: :type prefix: str :param other_prefix: :type other_prefix: str

scale_constraint_to_local(scale_constraint, keep_negative_scale=True)

Scale constraint can work wrong when given the parent matrix. Disconnect the parent matrix to remove this behavior. Reconnect using scale_constraint_to_world if applying multiple constraints.

Parameters

scale_constraint (str) – The name of the scale constraint to work on.

scale_constraint_to_world(scale_constraint)

Works with scale_constraint_to_local.

Parameters

scale_constraint (str) – The name of the scale constraint affected by scale_constraint_to_local.

duplicate_joint_section(joint, name='')

Joint chains ususally have a parent and a child along the chain. This will duplicate one of those sections. You need only supply the parent joint.

Parameters
  • joint (str) – The name of the joint to duplicate.

  • name (str) – The name to give the joint section.

Returns

[duplicate, sub duplicate]. If no sub duplicate, then [duplicate, None]

Return type

list

transforms_to_joint_chain(transforms, name='')

Given a list of transforms, create a joint chain.

Parameters
  • transforms (list) – List of transforms. Their positions will be used to set joint positions.

  • name (str) – The description to give the joints.

Returns

The names of the joints created.

Return type

list

positions_to_joint_chain(positions, name='')
Parameters
  • positions (list) – List of vectors. [[0,0,0],[0,0,0],…]

  • name (str) – Description to give the joints

attach_to_closest_transform(source_transform, target_transforms)

Attach the source_transform to the closest transform in the list of target_transforms.

Parameters
  • source_transform (str) – The name of a transform to check distance to.

  • target_transforms (list) – List of transforms. The closest to source_transform will be attached to it.

set_space_scale(scale_x, scale_y, scale_z, transform)
connect_inverse_scale(transform, joint)
randomize(translate=[0.1, 0.1, 0.1], rotate=[1, 1, 1], scale=[0.1, 0.1, 0.1], transforms=None)

Good for giving subtle randomness to many transforms.

Args

translate (list): 3 value list. The values work as the amount it can deviate in positive and negative. rotate (list): 3 value list. The values work as the amount it can deviate in positive and negative. scale (list): 3 value list. How much the scale can deviate from 1.

fix_locator_shape_position(locator_name)
set_translateX_limit(transform, min_value=None, max_value=None)
set_translateY_limit(transform, min_value=None, max_value=None)
set_translateZ_limit(transform, min_value=None, max_value=None)
set_rotateX_limit(transform, min_value=None, max_value=None)
set_rotateY_limit(transform, min_value, max_value)
set_rotateZ_limit(transform, min_value, max_value)
orig_matrix_match(transform, destination_transform)

This command is to be used for space switching. the transforms need to have origMatrix origMatrix is a matrix attribute that should store the original worldMatrix of the transform and destination_transform. By doing this it is possible to match any transform to any transform that has origMatrix. It basically saves out how the two transforms relate spacially. origMatrix needs to be added to the transform before animation/posing happens and before this command runs.