JZ Autorig Python Documentation
Table of Contents
- Common Modules
- Humanoid Rig Modules
- Quadruped Rig Modules
- Common Functions
Common Modules
FK Chain
from rigging_framework.templates.common.modules import fk_chain
def build(list_of_objects, name_or_none="FK_Chain", replace_in_name=(), add_prefix="", add_suffix="", scale=1,
color="blue", point_constraint=True, orient_constraint=True, scale_constraint=False,
virtual_constraints=False):
"""
Builds an fk chain based on given parameters
:param list[str] list_of_objects: list of objects to build chain grom
:param str or None name_or_none: if name is None then chain elements will be named after objects
:param tuple replace_in_name: tuple of pairs (tuples) - it can replace substrings in the name
:param str add_prefix: will add prefix to FK controls
:param str add_suffix: will add suffix to FK controls
:param float scale: scale of controls
:param str color: string name for color (blue, red, yellow, etc...)
:param bool point_constraint: does this chain control translation
:param bool orient_constraint: does this chaing control rotation
:param bool scale_constraint: does this chain control scale
:param bool virtual_constraints: whether constraints will be built during the build or saved for later
:return dict:
result = {"Controls": list of controls
"Control_Groups": list of control groups
"Module_Group": main module group name}
"""
Ribbon
from rigging_framework.templates.common.modules import ribbon
def build(list_of_objects, name="Ribbon", attach_objects=True, sticky=False, make_controls=False, scale=1,
surface_up=(0, 1, 0), virtual_constraints=False):
"""
Builds a ribbon based on selected objects positions, sticky or non sticky
:param list[str] list_of_objects: list of objects or joints to build ribbon along
:param str name: name of the ribbon module
:param bool attach_objects: whether selected objects will be attached to the ribbon - (overriden by make controls)
:param bool sticky: whether or not we want this ribbon to be sticky or sliding on the surface
:param bool make_controls: whether or not we want to make offset controls on this ribbon (overrides attach objects)
:param float scale: scale of the ribbon
:param float[3] surface_up: we need this to determine up from the surface - perpendicular vector to it
:param bool virtual_constraints: whether or not constraints are virtual (will be build after the tool executes)
:return dict:
result = {"Controls": list of controls
"Module_Group": main ribbon group name
"Control_Groups": list of control offset groups
"Ribbon_Surface": ribbon surface object}
"""
Humanoid Rig Modules
Finger Rig
from rigging_framework.templates.humanoid_rig.modules import finger_rig
def build(finger_joints, name_or_none, add_prefix=None, add_suffix="_Fk_Ctrl",
replace_in_name=(("FK_", ""), ("_Jnt", "")),
stretch_amount=10.0,
scale=1.0, virtual_constraints=False):
"""
Builds a simple fk finger based on fk chain,
Expects certain hard-coded conventions that will affect finger behaviour (will be updated):
"thumb", "index", "middle", "ring", "pinky"
"left", "right" or "_l", "_r"
:param list[str] finger_joints: list of finger joints
:param str or None name_or_none: name of the module or it will adopt name of the object for control names
:param str add_prefix: adds prefix to control names
:param str add_suffix: adds suffix to control names
:param tuple replace_in_name: tuple of two strings - replace substring with another substring from object to control
:param float scale: scale of controls
:param float stretch_amount: allowed amount to stretch (10.0 - default)
:param bool virtual_constraints: build constraints or leave them for later...
:return dict:
result = {"Module_Group": Module group name
"Main_Node": Main node - first finger control
"Controls": List of finger controls
"Control_Groups": List of finger control groups
"Finger_Pmas": dictionary of finger plus minus nodes with keys: bend, sway, curl etc... }
"""
Global Control
from rigging_framework.templates.humanoid_rig.modules import global_control
def build(name, root_skeletal_joint, scale=1.0, up_vector=(0, 1, 0)):
"""
Builds a global control and hierarchy
:param str name: Name of the global control
:param str root_skeletal_joint: Name of the root skeletal joint
:param float scale: Scale of the control
:param float[3] up_vector: Up vector of the control
:return str: Global control name
"""
Hand Rig
from rigging_framework.templates.humanoid_rig.modules import hand_rig
def build(name, cog_ctrl, ikfk_switch_ctrl, ik_main_node, hand_joint, thumb_joints, index_joints, middle_joints,
ring_joints, pinky_joints, scale):
"""
Builds an hand rig
:param str name: Name of the module
:param str cog_ctrl: Cog control name in the rig (needed to parent hand under)
:param str ikfk_switch_ctrl: Name of the ikfk switch control
:param str ik_main_node: Name of the main ik node to attach the hand to
:param str hand_joint: Name of the hand joint
:param list[str] thumb_joints: List of thumb joints
:param list[str] index_joints: List of index joints
:param list[str] middle_joints: List of middle joints
:param list[str] ring_joints: List of ring joints
:param list[str] pinky_joints: List of pinky joint
:param float scale: Scale of the controls
:return str: Ik hand control name
"""
Hips Rig
from rigging_framework.templates.humanoid_rig.modules import hips_rig
def build(name, pelvis_jnt, cog_ctrl,
left_hip_jnt, left_ik_hip_joint, left_hip_control_fk_grp, left_leg_ikfk_switch, left_ankle_jnt,
right_hip_jnt, right_ik_hip_joint, right_hip_control_fk_grp, right_leg_ikfk_switch, right_ankle_jnt,
scale):
"""
Build hips rig for IKFK legs and pelvis
:param str left_hip_jnt: left hip joint
:param str left_ik_hip_joint: left ik hip joint
:param str left_hip_control_fk_grp: left hip fk control offset group
:param str left_leg_ikfk_switch: left leg ikfk switch
:param str left_ankle_jnt: left ankle joint
:param str right_hip_jnt: right hip joint
:param str right_ik_hip_joint: right ik hip joint (assumes we have fk and ik joints)
:param str right_hip_control_fk_grp: right hip fk control offset group
:param str right_leg_ikfk_switch: right leg ikfk switch
:param str right_ankle_jnt: right ankle joint
:param str pelvis_jnt: pelvis joint
:param str cog_ctrl: COG control
:param str name: name of the module
:param float scale: controls scale
:return str: pelvis control name
"""
IK Ribbon Spine
from rigging_framework.templates.humanoid_rig.modules import ik_ribbon_spine
def build(name, spine_joints, control_names=("Hip", "Abdomen", "Chest"), main_cog_control=True,
world_orientated_controls=True, middle_control_constrained=True, scale=1.0, up_vector=(0, 1, 0),
aim_vector=(1, 0, 0), virtual_constraints=False):
"""
Builds IK ribbon spine for bipeds (part of IKFK spine)
:param str name: Name of the rig module
:param list[str] spine_joints: Spine joints starting from the hip, ending with the chest
:param float scale: sScale of the controls
:param list[str] control_names: Names of 3 ik controls
:param bool main_cog_control: Whether or not to build main cog control
:param bool world_orientated_controls: Whether or not we want the controls to be world orientated or object
:param bool middle_control_constrained: Whether we want middle control to be constrained between outer ones
:param float[3] up_vector: Determines the up of the control and the ribbon
:param float[3] aim_vector: Determines the forward of the control and the ribbon
:param bool virtual_constraints: Whether or not constrains are going to be built right away or virtually
:return dict:
result = {"Main_Node": Main node in the module (Hips control)
"Controls": List of controls
"Module_Group": Main module group
"Scaling_Groups": Groups that require global scaling
"Controls_Grp": List of control offset groups
"Ribbon_Surface": Ribbon surface transform
"Ribbon_Tweak_Controls": List of ribbon tweaking controls
"""
IKFK Limb
from rigging_framework.templates.humanoid_rig.modules import ikfk_limb
def build(name, start_joint, mid_joint, end_joint, scale=1.0, pole_vector_distance=1.0, virtual_constraints=False,
name_or_none=None,
replace_in_name=(("_Jnt", ""), ("FK_", "")),
add_prefix="",
add_suffix="_FK_Ctrl",
):
"""
Builds the module based on given parameters
This module has to be build on almost straight limb - it will not straighten the bent limb...
:param str name: Name of the module
:param str start_joint: Upper arm or Upper leg
:param str mid_joint: Knee or elbow
:param str end_joint: Ankle or hand
:param scale float scale: Scale of controls
:param float pole_vector_distance: multiplier how far pole vector should land
:param bool virtual_constraints: do we want to constraint right away or leave it for later
:param str name_or_none: Name of the FK module - otherwise it will name after joints
:param list(tuple) replace_in_name: Substrings in fk joints to be replaced default FK and JNT
:param str add_prefix: add prefix to FK controls?
:param str add_suffix:
:return dict:
result = {"Main_Node": End locator of the limb system (Use this instead of IK)
"Controls": Pole vector control + FK controls
"Module_Group": Main module group
"Gizmos_Grp": Gizmos (Display stuff)
"Control_Groups": Offsets for all the controls above
"IKFK_Switch_Ctrl": IKFK switch control
"IK_Handle": IK handle node}
"""
IKFK Limb Tweakable
from rigging_framework.templates.humanoid_rig.modules import ikfk_limb_tweakable
def build(name, start_joint, mid_joint, end_joint, scale=1.0, pole_vector_distance=1.0, aim_vector=(1, 0, 0),
up_vector=(0, 1, 0), virtual_constraints=False):
"""
Builds the module based on given parameters
This module has to be build on almost straight limb - it will not straighten the limb...
:param str name: Name of the module
:param str start_joint: Upper arm or upper leg
:param str mid_joint: Middle joint like knee or elbow
:param str end_joint: End joint like ankle or hand
:param float scale: Scale of the controls
:param float pole_vector_distance: Multiplier how far pole vector should land
:param float[3] aim_vector: What is the aim vector for this system - where should it be aiming forward
:param float[3] up_vector: Whats the up vector fir this system - what is up for it in the coordinate system
:param bool virtual_constraints: Do we want to build constraints or leave that for later
:return dict:
result = {"Main_Node": Main limb node - locator in the hand/ankle which can be used to attach things to,
"Controls": IKFK limb controls + tweaker control,
"Module_Group": Main module group,
"Gizmos_Grp": Gizmos - display elements (guide curves),
"Control_Groups": IKFK limb control groups and tweaker control group,
"IKFK_Switch_Ctrl": IKFK switch control name}
"""
IKFK Spine
from rigging_framework.templates.humanoid_rig.modules import ikfk_spine
def build(name, spine_joints, ik_drives_fk=True, scale=1.0, up_vector=(0, 1, 0), aim_vector=(1, 0, 0),
virtual_constraints=False):
"""
Builds ikfk ribbon spine with a switch for biped
:param str name: Name of the module
:param list[str] spine_joints: List of spine joints
:param bool ik_drives_fk: Default build is IK driving FK, but there is opposite option if needed
:param float scale: Scale of the controls
:param float[3] up_vector: Determines the up of the control and the ribbon
:param float[3] aim_vector: Determines the forward of the control and the ribbon
:param bool virtual_constraints: Whether or not constrains are going to be built right away or virtually
:return dict:
result = {"Main_Node": Main COG control node
"Controls": IK spine controls + FK spine controls
"Module_Group": Main module group
"Control_Groups": IK spine control groups + FK spine control groups,
"Ribbon_Surface": Name of the ribbon surface node,
"Ribbon_Tweak_Controls": Tweaker controls for the ribbon}
"""
Neck And Head Rig
from rigging_framework.templates.humanoid_rig.modules import neck_and_head
def build(name, neck_joints, parent_joint, scale=1.0, neck_has_orientation=False, head_has_orientation=True,
aim_vector=(1, 0, 0), up_vector=(0, 1, 0), virtual_constraints=False):
"""
Builds bipedal or quadrupedal ribbon neck (can handle 3 or more joints)
:param str name: Name of the module
:param list[str] neck_joints: Starting from the neck base, ending with the head
:param str parent_joint: Parent joint - chest or so
:param float scale: Scale of controls
:param bool neck_has_orientation: Whether the neck controls will be orientated like the rig orientation or follow the joints
:param bool head_has_orientation: Whether the head control will be orientated like the rig orientation or follow the joint
:param float[3] aim_vector: The aim vector for this module
:param float[3] up_vector: Up vector for the module
:param bool virtual_constraints: When to build the constraints
:return dict:
result = {"Main_Node": Neck base control - main node
"Controls": Neck base, neck mid, head - controls
"Module_Group": Main module group
"Control_Groups": Control groups - neck base, mid, head
"""
Shoulder Rig
from rigging_framework.templates.humanoid_rig.modules import shoulder_rig
def build(name, cog_ctrl, chest_joint, shoulder_joint, ik_arm_joint, arm_fk_ctrl_grp, scale):
"""
Builds a shoulder rig
:param str name: Name of the module
:param str cog_ctrl: Name of the COG control
:param str chest_joint: Chest joint
:param str shoulder_joint: Shoulder joint
:param ik_arm_joint: IK arm joint (assumes we have IK chain and FK chain)
:param str arm_fk_ctrl_grp: Arm FK control group
:param float scale: Scale of rig controls
:return str: Shoulder control
"""
Quadruped Rig Modules
Front IKFK Leg
from rigging_framework.templates.quadruped_rig.modules import front_ikfk_leg
def build(name, shoulder_joint, upper_knee_joint, lower_knee_joint, ankle_joint, scale=1.0, orientation=(0, 0, 0)):
"""
Builds the front IKFK quadrupedal leg based on given parameters
:param str name: Name of the module
:param str shoulder_joint: Name of the shoulder bone
:param str upper_knee_joint: Name of the upper knee joint (assumes quadruped would have upper and lower knee)
:param lower_knee_joint: Name of the lower knee joint (assumes quaruped would have upper and lower knee)
:param joint ankle_joint: Name of the ankle joint
:param float scale: Scale of the controls
:param float[3] orientation: Orientation of the system (default 0, 0, 0)
:return dict:
result = {"Main_Node": Main node - a locator to which you can attach footrig and other elements, follows IK and FK
"Controls": List of controls - lower knee pv, ik shoulder, fk controls
"Do_Not_Touch_Grp": IK system group
"Gizmos_Grp": Group containing visual gizmos - guides
"Controls_Grp": Main controls group
"IKFK_Switch_Ctrl": ikfk_switch_ctrl}
"""
IKFK Tail Rig
from rigging_framework.templates.quadruped_rig.modules import ikfk_tail_rig
def build(name, tail_joints, orientation=(0, 0, 0), scale=1.0, virtual_constraints=False):
"""
Builds ikfk tail
:param str name: Module name
:param list[str] tail_joints: List of tail joints
:param float[3] orientation: orientation of the rig (default 0 0 0)
:param float scale: scale of the controls
:param virtual_constraints: whether or not constraining will be executed in this script or saved for later
:return dict:
result = {"Main_Node": main_tail_ctrl,
"Controls": [main_tail_ctrl] + fk_tail_data["Controls"] + ik_tail_data["Controls"],
"Do_Not_Touch_Grp": do_not_touch_grp,
"Scaling_Grp": scaling_jnt_grp,
"Controls_Grp": all_controls_grp}
"""
Quad IK Ribbon Spine
rigging_framework.templates.quadruped_rig.modules.quad_ik_ribbon_spine
def build(name, spine_joints, control_names=("Hip", "Abdomen", "Chest"), main_cog_control=True,
world_orientated_controls=True, middle_control_constrained=True, scale=1.0, orientation=(0, 0, 0),
virtual_constraints=False):
"""
Builds ribbon spine for quadruped rig
:param str name: Name of the module
:param list[str] spine_joints: Joints starting from the hip, ending with the chest
:param float scale: Scale of controls
:param list[str] control_names: Names of 3 ik controls
:param str main_cog_control: Whether to build main cog control
:param bool world_orientated_controls: Whether we want the controls to be world orientated or object
:param bool middle_control_constrained: Whether we want middle control to be constrained between outer ones
:param float[3] orientation: Default orientation of the ik ribbon spine (0, 0, 0) default
:param bool virtual_constraints: Whether constrains are going to be built right away or virtually
:return:
result = {"Main_Node": COG control - main rig node
"Controls": Controls - (COG), Hip, Abdomen, Chest,
"Do_Not_Touch_Grp": Rig elements that are supposed to be hidden,
"Scaling_Groups": Groups requiring individual scaling,
"Controls_Grp": Offset groups for controls above
"""
Quad IKFK Spine
from rigging_framework.templates.quadruped_rig.modules import quad_ikfk_spine
def build(name, spine_joints, ik_drives_fk=True, scale=1.0, orientation=(0, 0, 0), skip_joints_missing_str=()):
"""
Builds ikfk ribbon spine with a switch for quadruped
:param str name: Name of the module
:param list[str] spine_joints: List of spine joints
:param bool ik_drives_fk: By default IK drives FK spine - but it could be opposite
:param float scale: Scale of the controls
:param float[3] orientation: Default orientation of IK controls (0, 0, 0) default
:param skip_joints_missing_str: When duplicating chains to create IK and FK chains - deletes the joints that do not contain this string
:return dict:
result = {"Main_Node": COG Control for the spine - Main Node,
"Controls": IK Spine controls and FK controls,
"Do_Not_Touch_Grp": Group containing hidden rig elements,
"Scaling_Groups": Group requiring individual scaling,
"Controls_Grp": Control offset groups for controls above}
"""
Quad Neck And Head Rig
from rigging_framework.templates.quadruped_rig.modules import quad_neck_and_head
def build(name, neck_joints, scale=1.0, neck_has_orientation=False, head_has_orientation=True, orientation=(0, 0, 0)):
"""
Builds quad ribbon neck and head system
:param str name: Name of the module created
:param list[str] neck_joints: Neck joints starting from the hip, ending with the chest
:param float scale: Scale of controls
:param bool neck_has_orientation: Whether the neck controls will be orientated like the rig orientation or follow the joints
:param bool head_has_orientation: Whether the head control will be orientated like the rig orientation or follow the joint
:param float[3] orientation: What is the default orientation for this rig
:return dict:
result = {"Main_Node": ribbon_controls["Neck_Base"],
"Controls": [ribbon_controls["Neck_Base"], ribbon_controls["Neck_Mid"], ribbon_controls["Head"]],
"Do_Not_Touch_Grp": do_not_touch_grp,
"Scaling_Groups": [ribbon_joints_scaling_grp],
"Controls_Grp": ribbon_control_groups["Neck_Base"]}
"""
Rear IKFK Leg
from rigging_framework.templates.quadruped_rig.modules import rear_ikfk_leg
def build(name, hip_joint, upper_knee_joint, lower_knee_joint, ankle_joint, scale=1.0, orientation=(0, 0, 0)):
"""
Builds the rear leg module based on given parameters
:param str name: Name of the module
:param str hip_joint: Name of the hip joint
:param str upper_knee_joint: Upper knee joint
:param str lower_knee_joint: Lower knee joint
:param str ankle_joint: Ankle joint
:param float scale: Scale of the controls
:param float[3] orientation: Default module/controls orientation (0, 0, 0) is default
:return dict:
result = {"Main_Node": foot_locator,
"Controls": [lower_knee_pole_vec_ctrl, upper_knee_pole_vec_ctrl, hip_ik_control] + fk_controls,
"Do_Not_Touch_Grp": ik_system_grp,
"Gizmos_Grp": gizmo_group,
"Controls_Grp": control_group,
"IKFK_Switch_Ctrl": ikfk_switch_ctrl}
"""
Common Functions
Virtual Constraints
# For virtual constraints in your code steps use constraints module:
from rigging_framework.templates.common.utilities import constraints
# initialize mapping system so that we can start storing constraints created in individual code steps:
constraints.initialize_mapping()
# virtual point constraint
constraints.point_constraint(masters=["Master_Object"], slave=["Slave_Object"], maintain_offset=True, skip_translate=["x"], use_mapping_file=True)
# virtual orient constraint
constraints.orient_constraint(masters, slave, maintain_offset, skip_rotate, interp_type, use_mapping_file=True)
# virtual parent constraints
constraints.parent_constraint(masters, slave, maintain_offset, skip_translate, skip_rotate, interp_type, use_mapping_file=True)
# virtual scale constraint
constraints.scale_constraint(masters, slave, maintain_offset, skip_scale, use_mapping_file=True)
# This will build all the constraints stored in mapping file initialized earlier and clear out the mapping file:
constraints.build_constraints(flush_data=True, use_mapping_file=True)
Global Variables
# import global variables module
from rigging_framework import global_variables
# set global variable value:
global_variables.set(variable_name, value)
# get variable value (even if it was saved in previous steps)
variable_value = global_variables.get(variable_name)
Step Arguments
# import global variables module
from rigging_framework import global_variables
# accessing all arguments from the step
args = global_variables.get_step_arguments()
# accessing specific argument
root_joint = args["root_joint"]
Skin Weights
# import skinning module
from rigging_framework.templates.common.utilities import skin_clusters
# save weights (select skinned object and run this to specify file)
skin_clusters.export_weights()
# load weights
skin_clusters.import_weights_from_file(geometry, weights_file)
Control Shapes
# import shapes module
from rigging_framework.templates.common.utilities import shapes
# save shapes to a file (select shapes run this to specify file)
shapes.export_shapes()
# import shapes from file
shapes.import_shapes_from_file(file_path)