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) |
This will orient the joint using the attributes created with OrientJointAttributes. |
BoundingBox (thing) |
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 () |
Function Summary
has_constraint (transform) |
Find out if a constraint is affecting the transform. |
is_transform_default (transform) |
Check if a transform has the default values (identity matrix). |
get_non_default_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. |
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_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_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. |
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. |
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. |
add_orient_joint (joint) |
Add orient joint. |
orient_x_to_child (joint[, invert]) |
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_xform ([prefix, suffix, string_search]) |
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. |
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. |
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. |
attach_to_closest_transform (…) |
Attach the source_transform to the closest transform in the list of target_transforms. |
create_ghost_follow_chain (transforms) |
|
create_ghost_chain (transforms) |
A ghost chain has the same hierarchy has the supplied 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) |
Functions
-
has_constraint
(transform)¶ Find out if a constraint is affecting the transform.
Parameters: transform (str) – The name of a 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
-
get_non_default_transforms
()¶ 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.
-
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_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_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:
-
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:
-
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:
-
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
-
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’, connect_xform=False, 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:
-
orient_attributes
(scope=None)¶ 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.
-
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
(joint, invert=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)¶ 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)¶ 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_xform
(prefix=None, suffix=None, string_search=None)¶ 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
-
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
-
scale_constraint_to_local
(scale_constraint)¶ 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:
-
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:
-
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.
-
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
-
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)¶