Last active
August 29, 2015 14:25
-
-
Save tokejepsen/c54dabe11d64ee5d54bd to your computer and use it in GitHub Desktop.
Bake Shape to Blendshape
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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