Export Selected Bake Anim Start/End Python


#1

I spent some time yesterday creating a simple export script for animations. The script selects the root bone, puts it in world space, runs export selected to create a FBX, and then puts the root bone back under it’s original parent. I found in doing this that the export selected plugin is actually pretty broken code wise :confused:.

To actually get the FBX to save the animation, I have to use FBXExportBakeComplexAnimation. This command has start/end values, but they do not seem to effect the FBX? I can set the FBXExportBakeComplexStart to 5 and the FBXExportBakeComplexEnd to 10 and if my timeline is 1 to 100 it will still bake 1 to 100. Thoughts?

def ExportAnimation():

mc.select( clear=True )
mc.select( "root" )

hasParent = bool(mc.listRelatives("root", parent = True))
if (hasParent):
    parentObj = mc.listRelatives("root", parent = True)
    mc.parent("root", w = True)
    print "root moved to world"
else:
    print "root in world"

basicFilter = "*.fbx"
chosenPath = mc.fileDialog2(fileFilter = basicFilter, dialogStyle = 2)
print chosenPath[0]
fileName = '"' + chosenPath[0] + '"'
bakeStartValue = ' FBXExportBakeComplexStart -v ' + str(mc.floatField( "bakeStartField", editable = True, q = True, value = 1))
print "bake starts at " + str(bakeStartValue)
bakeEndValue = ' FBXExportBakeComplexEnd -v ' + str(mc.floatField( "bakeEndField", editable = True, q = True, value = 1))
print "bake ends at " + str(bakeEndValue)
mel.eval('FBXExport -f ' + fileName + ' -s' + ' FBXExportAnimationOnly -v True FBXExportBakeComplexAnimation -v True' + bakeStartValue + bakeEndValue + ' FBXExportBakeComplexStep -v 1 FBXExportBakeResampleAll -v True')
print 'FBXExport -f ' + fileName + ' -s' + ' FBXExportAnimationOnly -v True FBXExportBakeComplexAnimation -v True' + bakeStartValue + bakeEndValue + ' FBXExportBakeComplexStep -v 1 FBXExportBakeResampleAll -v True'

if (hasParent):
    mc.parent("root", parentObj)
    print "root moved to parent"