Skip to content

Instantly share code, notes, and snippets.

@RedForty
Last active May 29, 2018 07:21
Show Gist options
  • Save RedForty/dab79a788786da5f259cec676390a869 to your computer and use it in GitHub Desktop.
Save RedForty/dab79a788786da5f259cec676390a869 to your computer and use it in GitHub Desktop.
Spine2Chest
from maya import cmds
from maya import mel
# If you want to mess with the Char_Anim globals, here you go. Not necessary, though.
# namespace, char = mel.eval('$tempVar = $char').split(':')
# namespace = mel.eval('$tempVar = stringArrayToString($namespc, " ")').split(" ")[0]
sel = cmds.ls(sl=True)
toon = sel[0].rpartition(':')[0]
chest_control = cmds.ls(toon + ':*_ac_cn_chest')[0]
spine_controls_all = cmds.ls(toon + ':*_ac_cn_spineFK*', type = 'transform')
spine_controls = []
for object in spine_controls_all:
if not 'offset' in object:
spine_controls.append(object)
locator = cmds.spaceLocator(n=chest_control + "_loc",p=[0,0,0])
cmds.setAttr(locator[0] + ".scale", 10,10,10) # Change scale here if you need to
constraint = cmds.parentConstraint(chest_control, locator)
cmds.delete(constraint)
constraint = cmds.parentConstraint(locator, chest_control)
trList = ['.tx','.ty','.tz','.rx','.ry','.rz']
for control in spine_controls:
for attr in trList:
try: cmds.setAttr(control + "%s" % attr, 0)
except: pass
cmds.setKeyframe(chest_control)
cmds.delete(constraint)
cmds.delete(locator)
cmds.select(sel)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment