Skip to content

Instantly share code, notes, and snippets.

@tokejepsen
Last active August 29, 2015 14:25
Show Gist options
  • Save tokejepsen/c54dabe11d64ee5d54bd to your computer and use it in GitHub Desktop.
Save tokejepsen/c54dabe11d64ee5d54bd to your computer and use it in GitHub Desktop.
Bake Shape to Blendshape
import maya.cmds as cmds
def bakeShapeToBlendShape(node, start, end):
step = 1.0 / end
bs_node = cmds.duplicate(node, n=node + '_blendshape')[0]
cmds.currentTime(end)
copy = cmds.duplicate(node)[0]
bs = cmds.blendShape(bs_node)[0]
cmds.blendShape(bs, edit=True, target=(bs_node, 1, copy, 1))
cmds.delete(copy)
for count in range(start, end):
index = count * step
cmds.currentTime(count)
copy = cmds.duplicate(node)[0]
cmds.blendShape(bs, edit=True,inBetween=True, target=(bs_node, 1, copy, index))
cmds.delete(copy)
for node in cmds.ls(selection=True):
cmds.currentTime(1)
bakeShapeToBlendShape(node, 1, 100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment