Skip to content

Instantly share code, notes, and snippets.

@tokejepsen
Created September 23, 2013 10:56
Show Gist options
  • Save tokejepsen/6668995 to your computer and use it in GitHub Desktop.
Save tokejepsen/6668995 to your computer and use it in GitHub Desktop.
bvh transfer
import maya.cmds as cmds
import maya.mel as mel
#load plugin
cmds.loadPlugin('fbxmaya.mll',quiet=True)
#getting file path and name
basicFilter = "Maya (*.ma)"
filePath=cmds.fileDialog2(fileFilter=basicFilter, dialogStyle=1,
fileMode=1,
caption='Import Animation')
cmd='file -import -type "mayaAscii" -ra true -mergeNamespacesOnClash false -namespace ":" -options "v=0;" -pr "M:/00719_grandpa/assets/Characters/Grandpa/publish/bvh_setup.mocap.v003.ma";'
mel.eval(cmd)
if filePath!=None:
#replace reference
cmds.file(filePath,loadReference='bvh_setupRN')
#setting timeline
lastKey=int(cmds.findKeyframe( 'mocap:RightUpLeg', which="last" ))
firstKey=int(cmds.findKeyframe( 'mocap:RightUpLeg', which="first" ))
cmds.playbackOptions(min=firstKey)
cmds.playbackOptions(max=lastKey)
cmds.playbackOptions(ast=firstKey)
cmds.playbackOptions(aet=lastKey)
cmds.currentTime(int(lastKey)/2)
#bake anim
mel.eval('HIKCharacterControlsTool;')
mel.eval('hikBakeToControlRig 0;')
#remove mocap
cmds.file(filePath,removeReference=True)
#final notification
confirm=cmds.confirmDialog( title='FINISHED', message='mocap transfered')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment