Skip to content

Instantly share code, notes, and snippets.

@EricTRocks
Created July 21, 2016 00:24
Show Gist options
  • Save EricTRocks/2604affe7b273e6f5d6ae1d16e920f6a to your computer and use it in GitHub Desktop.
Save EricTRocks/2604affe7b273e6f5d6ae1d16e920f6a to your computer and use it in GitHub Desktop.
Updates selected Maya joint's bind pose Credit to Ryan Porter (yantor3d)
# Credit to Ryan Porter (yantor3d)
from maya import cmds
for jnt in cmds.ls(sl=True, type="joint"):
matrixPlugs = cmds.listConnections(jnt + ".worldMatrix", type="skinCluster", p=True) or []
for mp in matrixPlugs:
bindPreMatrixPlug = mp.replace('matrix', 'bindPreMatrix')
if cmds.listConnections(bindPreMatrixPlug, s=True, d=False):
continue
print cmds.listConnections(bindPreMatrixPlug, s=True)
wim = cmds.getAttr(jnt + ".worldInverseMatrix")
cmds.setAttr(bindPreMatrixPlug, *wim, type="matrix")
cmds.skinCluster('skinCluster1', edit=True, recacheBindMatrices=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment