Back to 'Basics On How To Create Your Own Node'


IoTransform allows you to modify and manipulate Maya transform objects in much the same way as PyMel objects.
Arise returns an IoTransform object, or a subclass of it, in the rig_creation() method when the user access a ctrl or a joint.

The IoTransform __repr__ method has been reimplemented to return the long name of the Maya transform.
Which allows you to use it with the Maya's cmds library which usually expects a string name of the Maya object as its first argument.

For example: cmds.xform(self.my_joint.pointer, q=True, matrix=True)


and you can use it as an object with the many methods listed below.


To create an IoTransform object yourself:

from arise.utils.io_nodes.io_transform import IoTransform

IoTransform(name, existing=False)
Arguments:
  • name {str} -- Transform node name. Could be the name of an existing transform, based on the value of 'existing'
  • existing {bool} -- True means the transform exists already, False creates an empty transform (default: {False})

IoTransform properties/variables:


long_name -- {str} Returns the long name/full path name of the transform
short_name -- {str} Returns just the name of the transform
unique_name -- {str} Return the shortest unique name of the transform

uuid -- {str} Return the object UUID which is a str of number and letters giving the node a unique ID


IoTransform methods:


delete_history()
Simply delete history.



center_pivot()
Center pivot on boundingBox.



lock_attr(attr)
Lock an attribute on this transform.
Arguments:
  • attr {str} -- name of attribute to lock

unlock_attr(attr)
Unlock an attribute on this transform.
Arguments:
  • attr {str} -- name of attribute to unlock



hide_attr(attr)
Hide an attribute on this transform.
Arguments:
  • attr (str): name of an attribute on this transform


unhide_attr( attr)
Unhide an already hidden attribute on this transform.
Arguments:
  • attr (str): name of a hidden attribute on this transform


get_attr(attr, *args, **kwargs)
Return the value of an attribute. Takes any argument cmds.getAttr takes.
Arguments:
  • attr {str} -- name of attribute
Returns: Any value or state of the attribute. The number and type of values returned is dependent on the attribute type.



set_attr(attr, value, **kwargs)
Set the value of an attribute on this transform to 'value'. Takes any argument cmds.setAttr takes.
Arguments:
  • attr {str} -- name of the attribute
  • value {any type the attribute supports} -- the value to set the attribute to



list_attr(*args, **kwargs)
Return list of all attributes on this node. Takes any argument cmds.listAttr takes.

Returns: list -- of string names of attributes on this transform



add_attr(attr_name, *args, **kwargs)
Add a new attribute to this node. No need to specify node name as first arg. Takes any argument cmds.addAttr takes.
Arguments:
  • attr_name {str} -- name of new attribute
Returns: str -- long name of the new attribute. 'long_node_name.attr_name'



add_spacer_attr(char_min_length=6, if_needed=True)
Add a locked attribute as a spacer (only a visual attribute) using only underline characters.

Arguments:
  • char_min_length {int} -- the spacer min characters length (default: {6})
  • if_needed {bool} -- True skips creating spacer if the last attribute is already a spacer False creates
    it anyway (default: {True})



connect_attr(attr, driver_attr, **kwargs)
Connect driver attribute to drive an attribute on this node. Takes any argument cmds.connectAttr takes.
Arguments:
  • attr {str} -- name of an attribute on this transform
  • driver_attr {str} -- long name of driver attribute path. 'driver_node.driver_attr'


disconnect_attr(attrs, incoming=True)
Disconnect incoming connection or out-going connections to an attribute or attributes on this node.
If there is nothing to disconnect does nothing.
Arguments:
  • attrs {str or list} -- str name of an attribute or a list of str of attributes on this node
  • incoming {bool} -- True to disconnect incoming connections, False for out-going connections



parent(parent_to)
Parent this node under another node. Keeping it's position in place.
Arguments:
  • parent_to {str or None} -- name of a transform to parent under or None to parent to world


parent_relative(parent_to)
Parent this node under another node. Moving this node to keep it's local transformation values.
Arguments:
  • parent_to {None str} -- name of a transform to parent under, or None to parent to world


get_parent(generation=1)
Retrieve the parent or a grandparent of this node.
If the object is parented to the world, an empty string will be returned.
Arguments:
  • generation {int} -- the parent to return, 1=parent, 2=grandparent, and so on (default: {1})
Returns: str -- name of parent or grandparent, if parented to world returns an empty string



add_group_above(name, maintain_local_values=True)
Adds an empty group above this transform node.
Arguments:
  • name {str} -- how to name the new group node
  • maintain_local_values {bool} -- If set to True, the new group will be positioned at the grandparent's position.
    If False will position at this transform position transferring any local transformation values this transform might have. (default: {True})
Returns: IoTransform -- the new transform group above as an IoTransform object



set_visibility(state=False)
Turn visibility on or off.
Keyword Arguments:
  • state {bool} -- True will show, False will hide (default: {False})


freeze_transformations(**kwargs)
Simply freeze transformation on this node. Takes the same argument as cmds.makeIdentity().


set_translation(translation, space="world")
Set the translation values from list of 3 floats (XYZ). In world or object space.
Arguments:
  • translation {list} -- of 3 floats representing XYZ values
  • space {str} -- set the position in 'world' or 'object' space (default: {"world"})


get_translation(space="world")
Return the translation XYZ values in a list of 3 floats. In world or object space.
Arguments:
  • space {str} -- get the position in 'world' or 'object' space (default: {"world"})
Returns: list -- of 3 floats representing XYZ translation values



translate_by(values, space="object")
Relatively change translation values.
Arguments:
  • values {list} -- of 3 floats representing XYZ values
  • space {str} -- add to position in 'world' or 'object' space (default: {"object"})


set_rotation(rotation, space="world")
Set the rotation values from list of 3 floats (XYZ). In world or object space.
Arguments:
  • rotation {list} -- of 3 floats representing XYZ
  • space {str} -- set the rotation in 'world' or 'object' space (default: {"world"})



get_rotation(space="world")
Return the rotation XYZ values in a list of 3 floats. In world or object space.
Arguments:
  • space {str} -- get the rotation in 'world' or 'object' space (default: {"world"})
Returns: list -- of 3 floats representing rotation XYZ values



rotate_by(values, space="object")
Relatively change rotation values.
Arguments:
  • values {list} -- of 3 floats representing XYZ
  • space {str} -- add to rotation in 'world' or 'object' space (default: {"object"})


set_scale(scale, space="world")
Set the scale values from list of 3 floats (XYZ). In world or object space.
Arguments:
  • scale {list} -- of 3 floats representing XYZ
  • space {str} -- set the scale in 'world' or object' space (default: {"world"})


get_scale(space="world")
Return the scale XYZ values in a list of 3 floats. In world or object space.
Arguments:
  • space {str} -- get the scale in 'world' or 'object' space (default: {"world"})
Returns: list -- of 3 floats representing XYZ scale values



scale_attrs_connect()
Connect this node scaleY and scaleZ to scaleX then lock and hide them, so it can only be scaled uniformly.



set_color(color)
If this transform has a shape under it, set the color of the shapes using color overrides.
Arguments:
  • color {list or str} -- can take list of 3 floats RGB or str color name: values: 'red', 'blue', 'purple', 'green', 'yellow'



set_line_width(line_width)
If this transform has a curve shape under it, modify the curve line thickness.



lock_translation(x=True, y=True, z=True)
Lock translation attributes on this transform.
Arguments:
  • x (bool, optional): lock translateX. Defaults to True
  • y (bool, optional): lock translateY. Defaults to True
  • z (bool, optional): lock translateZ. Defaults to True


lock_rotation(x=True, y=True, z=True)
Lock rotation attributes on this transform.
Arguments:
  • x (bool, optional): lock rotateX. Defaults to True
  • y (bool, optional): lock rotateY. Defaults to True
  • z (bool, optional): lock rotateZ. Defaults to True



lock_scale(x=True, y=True, z=True)
Lock scale attributes on this transform.
Arguments:
  • x (bool, optional): lock scaleX. Defaults to True
  • y (bool, optional): lock scaleY. Defaults to True
  • z (bool, optional): lock scaleZ. Defaults to True


hide_translation(x=True, y=True, z=True)
Hide translation attributes on this transform.
Arguments:
  • x (bool, optional): hide translateX. Defaults to True
  • y (bool, optional): hide translateY. Defaults to True
  • z (bool, optional): hide translateZ. Defaults to True


hide_rotation(x=True, y=True, z=True)
Hide rotation attributes on this transform.
Arguments:
  • x (bool, optional): hide rotateX. Defaults to True
  • y (bool, optional): hide rotateY. Defaults to True
  • z (bool, optional): hide rotateZ. Defaults to True



hide_scale(x=True, y=True, z=True)
Hide scale attributes on this transform.
Arguments:
  • x (bool, optional): hide scaleX. Defaults to True
  • y (bool, optional): hide scaleY. Defaults to True
  • z (bool, optional): hide scaleZ. Defaults to True



lock_and_hide_attr(attr)
Lock and hide an attribute on this transform.
Arguments:
  • attr (str): name of an attribute on this transform



lock_and_hide_translation(x=True, y=True, z=True)
Lock and hide translation attributes on this transform.
Arguments:
  • x (bool, optional): lock and hide translateX. Defaults to True
  • y (bool, optional): lock and hide translateY. Defaults to True
  • z (bool, optional): lock and hide translateZ. Defaults to True


lock_and_hide_rotation(x=True, y=True, z=True)
Lock and hide rotation attributes on this transform.
Arguments:
  • x (bool, optional): lock and hide rotateX. Defaults to True
  • y (bool, optional): lock and hide rotateY. Defaults to True
  • z (bool, optional): lock and hide rotateZ. Defaults to True



lock_and_hide_scale(x=True, y=True, z=True)
Lock and hide scale attributes on this transform.
Arguments:
  • x (bool, optional): lock and hide scaleX. Defaults to True
  • y (bool, optional): lock and hide scaleY. Defaults to True
  • z (bool, optional): lock and hide scaleZ. Defaults to True



lock_and_hide_vis()
Lock and hide the visibility attribute on this transform.



lock_and_hide_transformations(vis=True)
Lock and hide all transformation attributes.
Arguments:
  • vis {bool} -- True to also lock and hide visibility attr (default: {True})


set_templated(state=True)
Set 'display type' to 'Template'.
Arguments:
  • state (bool, optional): True to template False to return to normal. Defaults to True



set_referenced(state=True)
Set 'display type' to 'Reference'.
Arguments:
  • state (bool, optional): True to reference False to return to normal. Defaults to True



reset_transformations()
Reset translation and rotation attributes to 0 and scale attributes to 1.



get_matrix(space="world")
Return this transform matrix as a list.
Arguments:
  • space {str} -- 'object' or 'world'. Get the matrix in object space or world space (default: {"world"})
Returns: list -- list of 16 floats representing the matrix



set_matrix(matrix, space="world")
Set this transform matrix.
Arguments:
  • matrix {list} -- list of 16 floats representing the matrix
  • space {str} -- 'object' or 'world'. Set the matrix in object space or world space (default: {"world"})


match_transformation_to(transform_name)
Match in world space, the translate, rotate and scale values to match the matrix of another transform node.
Arguments:
  • transform_name {str} -- long name of a transform node to match it's transformations


match_translation_to(transform_name)
Match in world space, the position of another transform node.
Arguments:
  • transform_name {str} -- long name of a transform node to match it's position


match_rotation_to(transform_name)
Match in world space, the rotation values of another transform node.
Arguments
  • transform_name {str} -- long name of a transform node to match it's rotation



match_scale_to(transform_name)
Match in world space, the scale values of another transform node.
Arguments:
  • transform_name {str} -- long name of a transform node to match it's scale



direct_connect(driver, translate=True, rotate=True, scale=True)
Direct connect a driver node to drive the transformation attributes on this node.
Arguments:
  • driver {str or IoTransform} -- the driver node in this direct connection
  • translate {bool} -- True to connect translate attributes (default: {True})
  • rotate {bool} -- True to connect rotate attributes (default: {True})
  • scale {bool} -- True to connect scale attributes (default: {True})


attr(attr)
A simple formatting method to return a str long name of this transform node + "." + attr.
Arguments:
  • attr {str} -- name of an attribute to return its full path
Returns: str -- long name of this transform node + "." + attr



aim_constraint_to(transforms, **kwargs)
Create an aim constraint in which this node is driven by other transform nodes.
Can take same arguments as cmds.aimConstraint().
Arguments:
  • transforms {list} -- of str names of driver transforms driving this constraint
Returns: str -- long name of the new constraint node



point_constraint_to(transforms, **kwargs)
Create a point constraint in which this node is driven by other transform nodes.
Can take same arguments as cmds.pointConstraint().
Arguments:
  • transforms {list} -- of str long names of transforms drivers of constraint
Returns: str -- long name of the new constraint node



orient_constraint_to(transforms, **kwargs)
Create an orient constraint in which this node is driven by other transform nodes.
Can take same arguments as cmds.orientConstraint().
Arguments:
  • transforms {list} -- of str names of transforms to driver the constraint
Returns: str -- long name of the new constraint node



scale_constraint_to(transforms, **kwargs)
Create a scale constraint in which this node is driven by other transform nodes.
Can take same arguments as cmds.scaleConstraint().
Arguments:
  • transforms {list} -- of str names of transforms to driver the constraint
Returns: str -- long name of the new constraint node



parent_constraint_to(transforms, **kwargs)
Create a parent constraint in which this node is driven by other transform nodes.
Can take same arguments as cmds.parentConstraint().
Arguments:
  • transforms {list} -- of str names of transforms to driver the constraint
Returns: str -- long name of the new constraint node



distance_from(dis_from)
Return, in Maya's units, how far this transform is from an object or position.
Arguments:
  • dis_from {list or str} -- list of XYZ global position or a name of a Maya Dag node.
Returns: float -- distance from this node to 'dis_from'



rename(new_name)
Rename this node.
Arguments:
  • new_name (str): new name for this node
Returns: str -- the new short name (might not be same as new_name if new_name not unique)



local_axis(state=True)
Turn on or off display of local axis.
Arguments:
  • state {bool} -- True to turn on False for off (default: {True})



get_shapes(skip_intermediate=False)
Return a list of long names of all the shapes under this transform, if any.
Arguments:
  • skip_intermediate {bool} -- True to skip any shape set as intermediate (default: {False})
Returns: list -- of str long names of all the shapes under this transform



set_rotation_order(rotation_order)
Set the rotation order on this transform.
Arguments:
  • rotation_order {str} --  rotation options: 'xyz', 'yzx', 'zxy', 'xzy', 'yxz', 'zyx'



get_rotation_order()
Return rotation order of this transform.
Returns: str -- rotation options: 'xyz', 'yzx', 'zxy', 'xzy', 'yxz', 'zyx'



select(**kwargs)
Select this transform. Takes any arguments cmds.select takes.



is_exists()
Return True if node exists else return False.



hide(**kwargs)
Hide this node or selection or all objects based on flags. Takes same arguments cmds.hide() takes.



show(**kwargs)
Show this node or selection or all objects based on flags. Takes same arguments cmds.showHidden() takes.



_____________________________________________

Get Arise at: https://www.ariserigging.com