Skip to content

Instantly share code, notes, and snippets.

@mclavan
Created November 5, 2014 02:44
Show Gist options
  • Save mclavan/d7301a7bea102c4402ed to your computer and use it in GitHub Desktop.
Save mclavan/d7301a7bea102c4402ed to your computer and use it in GitHub Desktop.
Padding Example
import pymel.core as pm
# Select joint chain.
# On selected joints.
# Create a local oriented control.
joint_system = pm.ls(selection=True, dag=True)
last_control = None
# Loop through selected joints
for current_joint in joint_system[0:-1]:
# Rename control and delete history
#ct_back_01_bind -> ct_back_01_icon
icon_name = current_joint.replace('_bind', '_icon')
pad_name = current_joint.replace('_bind', '_pad')
group_name = current_joint.replace('_bind', '_group')
# You issue stems here. Control > Pad > group1
# Because group1 was created last it will be on top of the system.
# The code below focuses on the pad which is in the middle of the system.
# Create a circle
control_icon = pm.circle(name=icon_name, radius=.6, normal=[1, 0, 0])[0]
# Create a pad
pad = pm.group(name=pad_name)
# Create Orient Group
group1 = pm.group(name=group_name) # This is your issue.
# Snap group to target joint.
# Snapping using parent constraint.
# kenny = pm.parentConstraint(current_joint, pad)
kenny = pm.parentConstraint(current_joint, group1)
# Delete parent constraint.
pm.delete(kenny)
# Do you want to parent constraint or orient constraint?
# Also you most likely do not need to maintainOffset because the system should have the same orientation as the system.
# Parent Constraint Joint to Control
pm.parentConstraint(control_icon, current_joint, mo=True, w=1)
if last_control:
# group1 is the top pad not pad.
pm.parent(pad, last_control)
last_control = control_icon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment