Circle control script
This script creates a series of circle controls and circle control groups for every joint selected.
Notes:
- All joints MUST be named with a "JT_" prefix, as we have been doing in class.
- Joints must be selected starting in a parent-child descending order; in other words, select the top-most parent joint first, then the next child joint, then the next child joint, etc
- The selection set for the spinal column would in the following order:
- JT_spine_lumbar
- JT_spine_thoracic
- JT_neck
- JT_head
- The script will create a control for each joint, and connect the rotation channels of the joint to the control. The control is then grouped by itself. If it is controlling a joint that is the child of another joint in the current selection, it will parent the control's group to the controller of the parent.
How to use:
Copy the script below the dashed line into the Python tab of your script editor. Select the joints you want to add controls to, making sure to select the joints in a parent-child descending order. In the script editor, choose command > execute.
-------------------------------------------------------------------------------------------------------------------
import maya.cmds as cmds
sl = cmds.ls(sl=1)
count = 0
lastS = None
for s in sl:
ctrlName = s.replace("JT_", "CTL_")
ctrl = cmds.circle( nr=(1, 0, 0), r=1, n=ctrlName)[0]
offset = cmds.group(ctrl, n="GRP_" + ctrl )
cmds.parentConstraint(s, offset, mo=0)
cmds.delete(cmds.parentConstraint(s, offset))
cmds.parentConstraint(ctrl, s, mo=0)
if count > 0 :
cmds.parent( offset, lastS )
count = count + 1
global lastS
lastS = ctrl
No comments:
Post a Comment