vtool.maya_lib.attr

Class Summary

Connections(node) Convenience for dealing with connections.
TransferConnections
LockState(attribute) This saves the lock state, so that an attribute lock state can be reset after editing.
LockNodeState(node) This saves the lock state of the node, so that all attributes lock state can be reset after editing.
RemapAttributesToAttribute(node, attribute) Create a slider switch between multiple attributes.
OrientJointAttributes([joint]) Creates attributes on a node that can then be used with OrientAttributes
MayaVariable(name) Convenience class for dealing with Maya attributes.
MayaNumberVariable(name) Convenience class for dealing with Maya numeric attributes.
MayaEnumVariable(name) Convenience class for dealing with Maya enum attributes.
MayaStringVariable(name) Convenience class for dealing with Maya string attributes.
StoreData([node])
Attributes(node) Still testing.
TransferVariables()
MayaNode([name]) Not fully implemented.
MultiplyDivideNode([name]) Convenience class for dealing with multiply divide nodes.

Function Summary

get_variable_instance(attribute) Get a variable instance for the attribute.
get_variable_instance_of_type(name, var_type)
get_message_attributes(node[, user_defined])
is_attribute(node_dot_attribute) Check if what is passed is an attribute.
is_attribute_numeric(node_dot_attribute) Check if the attribute exists and is numeric.
is_translate_rotate_connected(transform) Check if translate and rotate attributes are connected.
is_connected(node_and_attribute)
is_locked(node_and_attribute)
get_node_and_attribute(attribute) Split a name between its node and its attribute.
get_inputs(node[, node_only]) Get all the inputs into the specified node.
get_outputs(node[, node_only]) Get all the outputs from the specified node.
get_attribute_input(node_and_attribute[, …]) Get the input into the specified attribute.
get_attribute_outputs(node_and_attribute[, …]) Get the outputs from the specified attribute.
get_message_input(node, message)
transfer_attribute_values(source_node, …)
get_attribute_values(node[, keyable_only])
set_attribute_values(node, values)
transfer_variables() Not done
transfer_output_connections(source_node, …) Transfer output connections from source_node to target_node.
hide_attributes(node, attributes) Lock and hide the attributes specified in attributes.
hide_keyable_attributes(node) Lock and hide keyable attributes on node.
lock_attributes(node[, bool_value, …]) lock attributes on a node.
unlock_attributes(node[, attributes, …]) unlock attributes on a node.
lock_translate_attributes(node)
lock_rotate_attributes(node)
lock_scale_attributes(node)
remove_user_defined(node) Removes user defined attributes from a node.
set_color(nodes, color) Set the override color for the nodes in nodes.
set_color_rgb(nodes[, r, g, b]) Maya 2015 and above.
get_color(node)
get_color_of_side([side, sub_color]) Get the override color for the given side.
connect_vector_attribute(source_transform, …) Connect an X,Y,Z attribute, eg translate, rotate, scale.
connect_transforms(source_transform, …) Connect translate, rotate, scale from souce to target.
connect_translate(source_transform, …) Connect translate attributes
connect_rotate(source_transform, …) Connect rotate attributes.
connect_scale(source_transform, target_transform) Connect scale attributes.
connect_translate_into_pivots(…)
connect_translate_plus(source_transform, …) Connect translate attributes.
connect_translate_multiply(source_transform, …) Connect translate attributes with a multiplyDivide to multiply the effect.
connect_rotate_multiply(source_transform, …) Connect rotate attributes with a multiplyDivide to multiply the effect.
connect_scale_multiply(source_transform, …) Never use.
connect_visibility(attribute_name, target_node) Connect the visibility into an attribute
connect_plus(source_attribute, target_attribute) Connect source_attribute into target_attribute with a plusMinusAverage inbetween.
connect_plus_new(source_attribute, …[, …]) Not in use.
connect_multiply(source_attribute, …[, …]) Connect source_attribute into target_attribute with a multiplyDivide inbetween.
insert_multiply(target_attribute[, value]) Insert a multiply divide into the input attribute of target_attribute.
connect_blend(source_attribute1, …[, value]) Connect source 1 and source 2 into the target_attribute with and blendColors node.
connect_reverse(source_attribute, …) Connect source_attribute into target_attribute with a reverse node inbetween.
connect_equal_condition(source_attribute, …) Connect source_attribute into target_attribute with a condition node inbetween.
create_blend_attribute(source, target[, …]) Create an attribute to hook into a blendshape.
connect_message(input_node, …) Connect the message attribute of input_node into a custom message attribute on destination_node
connect_group_with_message(input_node, …)
disconnect_attribute(attribute) Disconnect an attribute.
get_indices(attribute) Get the index values of a multi attribute.
get_available_slot(attribute) Find the next available slot in a multi attribute.
get_slots(attribute) Given a multi attribute, get all the slots currently made.
get_slot_count(attribute) Get the number of created slots in a multi attribute.
create_title(node, name[, name_list]) Create a enum title attribute on node
create_vetala_type(node, value) Convenience to tag nodes that are vital to the auto rig.
get_vetala_type(node) Get the vetala type of a node.
get_vetala_nodes([vetala_type]) Get vetala nodes in the scene.
zero_xform_channels(transform) Zero out the translate and rotate.
add_orient_attributes(*args, **kwargs) Add orient attributes, used to automatically orient.
remove_orient_attributes(transform)

Functions

get_variable_instance(attribute)

Get a variable instance for the attribute.

Parameters:attribute (str) – node.attribute name
Returns:The instance of a corresponding variable.
Return type:object
get_variable_instance_of_type(name, var_type)
get_message_attributes(node, user_defined=True)
is_attribute(node_dot_attribute)

Check if what is passed is an attribute.

Returns:bool
is_attribute_numeric(node_dot_attribute)

Check if the attribute exists and is numeric.

Returns:bool
is_translate_rotate_connected(transform)

Check if translate and rotate attributes are connected.

Parameters:transform (str) – The name of a transform.
Returns:bool
is_connected(node_and_attribute)
is_locked(node_and_attribute)
get_node_and_attribute(attribute)

Split a name between its node and its attribute.

Parameters:attribute (str) – attribute name, node.attribute.
Returns:[node_name, attribute]
Return type:list
get_inputs(node, node_only=True)

Get all the inputs into the specified node.

Parameters:
  • node (str) – The name of a node.
  • node_only (str) – Whether to return the node name or the node name + the attribute eg. ‘node_name.attribute’
Returns:

The inputs.

Return type:

list

get_outputs(node, node_only=True)

Get all the outputs from the specified node.

Parameters:
  • node (str) – The name of a node.
  • node_only (str) – Whether to return the node name or the node name + the attribute eg. ‘node_name.attribute’
Returns:

The outputs.

Return type:

list

get_attribute_input(node_and_attribute, node_only=False)

Get the input into the specified attribute.

Parameters:
  • node_and_attribute (str) – The node_name.attribute name to find an input into.
  • node_only (str) – Whether to return the node name or the node name + the attribute eg. ‘node_name.attribute’
Returns:

The attribute that inputs into node_and_attribute

Return type:

str

get_attribute_outputs(node_and_attribute, node_only=False)

Get the outputs from the specified attribute.

Parameters:
  • node_and_attribute (str) – The node_name.attribute name to find outputs.
  • node_only (str) – Whether to return the node name or the node name + the attribute eg. ‘node_name.attribute’
Returns:

The nodes that node_and_attribute connect into.

Return type:

str

get_message_input(node, message)
transfer_attribute_values(source_node, target_node, keyable_only=True)
get_attribute_values(node, keyable_only=True)
set_attribute_values(node, values)
transfer_variables()

Not done

transfer_output_connections(source_node, target_node)

Transfer output connections from source_node to target_node.

Parameters:
  • source_node (str) – The node to take output connections from.
  • target_node (str) – The node to transfer output connections to.
hide_attributes(node, attributes)

Lock and hide the attributes specified in attributes. This has been tested on individual attributes like translateX, not attributes like translate.

Parameters:
  • node (str) – The name of a node.
  • attributes (list) – A list of attributes on node to lock and hide. Just the name of the attribute.
hide_keyable_attributes(node)

Lock and hide keyable attributes on node.

Parameters:node (str) –
lock_attributes(node, bool_value=True, attributes=None, hide=False)

lock attributes on a node.

Parameters:
  • node (str) – The name of the node.
  • bool_value (bool) – Whether to lock the attributes.
  • attributes (list) – A list of attributes to lock on node.
  • hide (bool) – Whether to lock and hide the attributes.
unlock_attributes(node, attributes=[], only_keyable=False)

unlock attributes on a node.

Parameters:
  • node (str) – The name of the node.
  • attributes (list) – A list of attributes to lock on node. If none given, unlock any that are locked.
  • only_keyable (bool) – Whether to unlock only the keyable attributes.
lock_translate_attributes(node)
lock_rotate_attributes(node)
lock_scale_attributes(node)
remove_user_defined(node)

Removes user defined attributes from a node.

set_color(nodes, color)

Set the override color for the nodes in nodes.

Parameters:
  • nodes (list) – A list of nodes to change the override color.
  • color (int) – The color index to set override color to.
set_color_rgb(nodes, r=0, g=0, b=0)

Maya 2015 and above. Set to zero by default. Max value is 1.0.

get_color(node)
get_color_of_side(side=’C’, sub_color=False)

Get the override color for the given side.

Parameters:
  • side (str) – ‘L’,’R’, ‘C’
  • sub_color (bool) – Whether to return a sub color.
Returns:

A color index for override color.

Return type:

int

connect_vector_attribute(source_transform, target_transform, attribute, connect_type=’plus’)

Connect an X,Y,Z attribute, eg translate, rotate, scale.

Parameters:
  • source_transform (str) – The name of a transform.
  • target_transform (str) – The name of a transform.
  • attribute (str) – eg, translate, rotate, scale.
  • connect_type (str) – ‘plus’ or ‘multiply’
Returns:

The nodes created.

Return type:

list

connect_transforms(source_transform, target_transform)

Connect translate, rotate, scale from souce to target.

connect_translate(source_transform, target_transform)

Connect translate attributes

Parameters:
  • source_transform (str) – The name of a transform.
  • target_transform (str) – The name of a transform.
connect_rotate(source_transform, target_transform)

Connect rotate attributes. This will automatically connect rotateOrder from source to target, if not already connected.

Parameters:
  • source_transform (str) – The name of a transform.
  • target_transform (str) – The name of a transform.
connect_scale(source_transform, target_transform)

Connect scale attributes.

Parameters:
  • source_transform (str) – The name of a transform.
  • target_transform (str) – The name of a transform.
connect_translate_into_pivots(source_transform, target_transform)
connect_translate_plus(source_transform, target_transform)

Connect translate attributes. If target_transform already has input connections, reconnect with plusMinusAverage to accomodate both.

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

the name of the plusMinusAverage node.

Return type:

str

connect_translate_multiply(source_transform, target_transform, value=1, respect_value=False)

Connect translate attributes with a multiplyDivide to multiply the effect.

Parameters:
  • source_transform (str) – The name of a transform.
  • target_transform (str) – The name of a transform.
  • value (float) – The multiply value. Set to 0.5 to translate target half of what source translates.
  • repsect_value (bool) – If respect value is True, then add a plus minus average to buffer the multiply divide.
Returns:

the name of the multiplyDivide node. If respect value return [multiply, plus]

Return type:

str

connect_rotate_multiply(source_transform, target_transform, value=1, respect_value=False)

Connect rotate attributes with a multiplyDivide to multiply the effect. This is dangerous because rotate is not calculated in the same linear way as translate. Probably shouldn’t be used because of Quaternion math. Would be better to use a double orient constraint.

Parameters:
  • source_transform (str) – The name of a transform.
  • target_transform (str) – The name of a transform.
  • value (float) – The multiply value. Set to 0.5 to rotate target half of what source translates.
  • repsect_value (bool) – If respect value is True, then add a plus minus average to buffer the multiply divide.
Returns:

the name of the multiplyDivide node. If respect value return [multiply, plus]

Return type:

str

connect_scale_multiply(source_transform, target_transform, value=1, respect_value=False)

Never use.

connect_visibility(attribute_name, target_node, value=1)

Connect the visibility into an attribute

Parameters:
  • attribute_name (str) – The node.attribute name of an attribute. Does not have to exists. Will be created if doesn’t exist.
  • target_node (str) – The target node to connect attribute_name into.
  • value (bool) – 0 or 1 whether you want the visibility on or off by default.
connect_plus(source_attribute, target_attribute, respect_value=False)

Connect source_attribute into target_attribute with a plusMinusAverage inbetween.

Parameters:
  • source_attribute (str) – The node.attribute name of an attribute.
  • target_attribute (str) – The node.attribute name of an attribute.
  • respect_value (bool) – Whether to edit the input1D list to accomodate for values in the target attribute.
Returns:

The name of the plusMinusAverage node

Return type:

str

connect_plus_new(source_attribute, target_attribute, respect_value=False)

Not in use. Connect source_attribute into target_attribute with a plusMinusAverage inbetween. Tried to make it better, but isn’t.

Parameters:
  • source_attribute (str) – The node.attribute name of an attribute.
  • target_attribute (str) – The node.attribute name of an attribute.
  • respect_value (bool) – Whether to edit the input1D list to accomodate for values in the target attribute.
Returns:

The name of the plusMinusAverage node

Return type:

str

connect_multiply(source_attribute, target_attribute, value=0.1, skip_attach=False, plus=True)

Connect source_attribute into target_attribute with a multiplyDivide inbetween.

Parameters:
  • source_attribute (str) – The node.attribute name of an attribute.
  • target_attribute (str) – The node.attribute name of an attribute.
  • skip_attach (bool) – Whether to attach the input into target_attribute (if there is one) into input2X of multiplyDivide.
  • plus (bool) – Whether to fix input connections in target_attribute to plug into a plusMinusAverage. Therefore not losing their influence on the attribute while still multiplying by the source_attribute.
Returns:

The name of the plusMinusAverage node

Return type:

str

insert_multiply(target_attribute, value=0.1)

Insert a multiply divide into the input attribute of target_attribute.

Parameters:
  • target_attribute (str) – The node.attribute name of an attribute.
  • value (float) – The float value to multiply the target_attribute by.
Returns:

The new multiply divide.

Return type:

str

connect_blend(source_attribute1, source_attribute2, target_attribute, value=0.5)

Connect source 1 and source 2 into the target_attribute with and blendColors node.

Parameters:
  • source_attribute1 (str) – The node.attribute name of an attribute.
  • source_attribute2 (str) – The node.attribute name of an attribute.
  • target_attribute (str) – The node.attribute name of an attribute.
  • value (float) – The amount to blend the 2 attributes.
Returns:

The name of the blendColors node

Return type:

str

connect_reverse(source_attribute, target_attribute)

Connect source_attribute into target_attribute with a reverse node inbetween.

Parameters:
  • source_attribute (str) – The node.attribute name of an attribute.
  • target_attribute (str) – The node.attribute name of an attribute.
Returns:

The name of the reverse node

Return type:

str

connect_equal_condition(source_attribute, target_attribute, equal_value)

Connect source_attribute into target_attribute with a condition node inbetween.

Parameters:
  • source_attribute (str) – The node.attribute name of an attribute.
  • target_attribute (str) – The node.attribute name of an attribute.
  • equal_value (float) – The value the condition should be equal to, in order to pass 1. 0 otherwise.
  • when hooking up enums to visibility. (Good) –
Returns:

The name of the condition node

Return type:

str

create_blend_attribute(source, target, min_value=0, max_value=10, value=0)

Create an attribute to hook into a blendshape.

Parameters:
  • source (str) – The node.attr name of an attribute to connect into a blendshape.
  • target (str) – the blendshape.weight name to connect into.
Returns:

multiplyDivide node.

Return type:

str

connect_message(input_node, destination_node, attribute)

Connect the message attribute of input_node into a custom message attribute on destination_node

Parameters:
  • input_node (str) – The name of a node.
  • destination_node (str) – The name of a node.
  • attribute (str) – The name of the message attribute to create and connect into. If already exists than just connect.
connect_group_with_message(input_node, destination_node, attribute)
disconnect_attribute(attribute)

Disconnect an attribute. Find its input automatically and disconnect it.

Parameters:attribute (str) – The name of an attribute that has a connection.
get_indices(attribute)

Get the index values of a multi attribute.

Parameters:attribute (str) – The node.attribute name of a multi attribute. Eg. blendShape1.inputTarget
Returns:A list of integers that correspond to multi attribute indices.
Return type:list
get_available_slot(attribute)

Find the next available slot in a multi attribute.

Parameters:attribute (str) – The node.attribute name of a multi attribute. Eg. blendShape1.inputTarget
Returns:The next empty slot.
Return type:int
get_slots(attribute)

Given a multi attribute, get all the slots currently made.

Parameters:attribute (str) – The node.attribute name of a multi attribute. Eg. blendShape1.inputTarget
Returns:The index of slots that are open. Indices are returned as str(int)
Return type:list
get_slot_count(attribute)

Get the number of created slots in a multi attribute.

Parameters:attribute (str) – The node.attribute name of a multi attribute. Eg. blendShape1.inputTarget
Returns:The number of open slots in the multi attribute
Return type:int
create_title(node, name, name_list=[])

Create a enum title attribute on node

Parameters:
  • node (str) – The name of a node
  • name (str) – The title name.
create_vetala_type(node, value)

Convenience to tag nodes that are vital to the auto rig.

get_vetala_type(node)

Get the vetala type of a node.

get_vetala_nodes(vetala_type=None)

Get vetala nodes in the scene.

zero_xform_channels(transform)

Zero out the translate and rotate. Set scale to 1.

Parameters:transform (str) – The name of a transform node.
add_orient_attributes(*args, **kwargs)

Add orient attributes, used to automatically orient.

Parameters:transform (str) – The name of the transform.
remove_orient_attributes(transform)