Component Base Class

Code author: Jeremy Ernst

class ART_Component(prefix='', suffix='', network_node=None, side='Left')[source]

Base class for defining a component (arm, leg, torso, single joint, etc) in ARTv2. All components should inherit from this class.

When creating a new component, here is a list of common attributes and functions you will want or need to override.

Type Name Description
attribute nice_name (string) The nice name of the component (as it will appear in UIs)
attribute category (string) The name of the category where this component will show up in the user interface. For example: “Limbs”, “Primitives”, etc.
attribute base_name The string base name of the component. This is a simple string used to identify the component type and append onto nodes created by the component. For example, on a leg component, the base_name is simply: “leg”
attribute has_sides Bool for whether or not the component supports different sides,like a leg or arm do.
attribute can_overwrite_names Bool for whether or not the user can overwrite the names of the joints of this component.
attribute joint_mover_file The relative path from the ARTv2 directory to the joint mover file of the component. For example, self.joint_mover_file = “resources/rigging_guides/root.ma”
attribute mirror_table A dictionary of translate and rotate attributes with their multiplier for mirroring values to mirrored controls.
function _add_metadata This method adds attributes you want to keep track of that are unique to your component. Make sure that you still call on the base class’s _add_metadata method to setup the required attributes.
change_num_joints(joints, offset_movers, state)[source]

Sets the build state (whether or not they will be created) of the given joints to the given state.

Parameters:
  • joints – List of PyNode joints to toggle build state on
  • offset_movers – List of PyNode offset movers to toggle visibility on.
  • state – The build state to set.
copy_settings()[source]

Copies the values of the class properties (things like number of twist joints, etc) and writes them to a temp file.

create_mirror(prefix, suffix, parent)[source]

Creates a mirror of the component, then mirrors its transformations.

Parameters:
  • prefix (str) – prefix to give the created mirrored component.
  • suffix (str) – suffix to give the created mirrored component.
  • parent (str) – parent joint for the created mirrored component.
Returns:

Instance of the mirrored component

example usage:
asset = rig_asset.ART_RigAsset()
leg = leg.BipedLeg(prefix="l")
mirror = leg.create_mirror(prefix="r", suffix="", parent="root")
delete()[source]

Deletes the component from the scene.

example usage:
asset = rig_asset.ART_RigAsset()
leg = leg.BipedLeg(prefix="l")
leg.delete()
duplicate()[source]

Creates a duplicate instance of self, with the same settings, parent, and transforms. A unique trailing suffix is appended to prevent naming issues.

example usage:
asset = rig_asset.ART_RigAsset()
leg = leg.BipedLeg(prefix="l")
leg.duplicate()
paste_settings()[source]

Retrieves values from the temp file (if it exists) and sets any properties of the class matching those stored in the temp file, to those values.

rename_joint(new_name, old_name, offset_mover)[source]

Renames a joint that the component creates. The component’s prefix and suffix will be maintained. For example, if the component has a prefix of “_l”, and it will create a joint named foot, the user can rename foot to ankle, and the new name will be l_ankle.

Parameters:
  • new_name (str) – The new name of the joint
  • old_name (str) – The old name of the joint
  • offset_mover – The offset mover (PyNode) for the joint
example usage:
asset = rig_asset.ART_RigAsset()
leg = leg.BipedLeg(prefix="l")
data = component_utils.get_joint_labels(leg.network_node)
leg.rename_joint("ankle", "foot", data.get("foot")[2])
reset_settings()[source]

Resets all values of the class properties to the default they had at creation.

set_mirror(mirror_metanode)[source]

Sets the mirror component if the passed in mirror component is of the same class type.

Parameters:mirror_metanode – The network node for the mirror component to be set.
set_side(new_side)[source]

Sets the side of a component if that components supports setting sides. Setting a side from left to right, for example, will change the local rotation axis to be mirrored on the joints.

Parameters:new_side – This can be any of the following: “left”, “Left”, “right”, “Right”, 0, 1
set_twist_joints(attr, new_number, attr_min, attr_max, keyword)[source]

Base logic for setting number of twist joints via properties in components like arm, leg.

Parameters:
  • attr – the property name
  • new_number – The new value to set the property to
  • attr_min – The minimum value of allowable values
  • attr_max – The maximum value of allowable values
  • keyword – The keyword to search mover nodes for
network_node

This property holds the network node that contains this component’s metadata.

parent

This property holds the joint name of the parent of this component.

prefix

This property holds the component’s prefix (optional)

Returns:Returns the component’s prefix.
Return type:str
suffix

This property holds the component’s suffix (optional)

Returns:Returns the component’s suffix.
Return type:str

Properties

prefix

This property holds the component’s prefix (optional)

Returns:Returns the component’s prefix.
Return type:str
suffix

This property holds the component’s suffix (optional)

Returns:Returns the component’s suffix.
Return type:str
parent

This property holds the joint name of the parent of this component.

network_node

This property holds the network node that contains this module’s metadata.