Export animation with specific frame range in Python

Anonymous

Export animation with specific frame range in Python

Anonymous
Not applicable

I am working on exporting animations from the start frame to the end frame that the user can enter the input value. I use "cmds.playbackOptions( animationStartTime=startTime, animationEndTime = endTime)" to get my animation start and end time, but it only get the frame range in time slider. I still got all keyframes in my exported fbx files.

Does anyone know how to just export the frame range I want by Python?

I use this command below to export the animation fbx file: 

cmds.file(fullName, force = True, options = "v = 0", type = "FBX export", preserveReferences = True, exportSelectedAnim = True) 

 

Also, I entered start and end value in File/Export Selection to test if I could get the frame range I want, but it doesn't work. I still got all keyframes in exported fbx file, which is wired because I thought that option is for choosing the frame range.

 

Thank you!!!

0 Likes
Reply
Accepted solutions (1)
6,054 Views
3 Replies
Replies (3)

rajasekaransurjen
Collaborator
Collaborator
Accepted solution

Hi,

Try..... "FBXExportSplitAnimationIntoTakes".

refer

http://download.autodesk.com/global/docs/maya2014/en_us/index.html?url=files/GUID-F109CCD1-CA5F-484D...

 

import maya.cmds as cmds
import maya.mel as mel
mel.eval("FBXExportSplitAnimationIntoTakes -clear;")
# Export Animation from frame 25 to 65
mel.eval('FBXExportSplitAnimationIntoTakes -v \"tata\" 25 65')
mel.eval('FBXExport -f "E:/_TEMP/myfile.fbx" -s')
0 Likes

Anonymous
Not applicable

Thank you sooo much!! It works!

0 Likes

Anonymous
Not applicable
Hi, rajasekaransurjen,
 

 

Thank you very much for answering my question. But I got a new one related to this. Hope you could help me!

 

The keyframe range works well, but I am trying to bake animation, change the Up Axis to Z, disable Embed Media when exporting. Just like the setting in Game Exporter in Maya

Capture.PNG

I tried to use the code below, but they just didn't work. 

Do you have any idea how to solve this? Are those the correct way? My code is like this:

 

mel.eval('FBXResetExport;')
mel.eval('FBXExportBakeComplexAnimation -v true;')
mel.eval('FBXExportEmbeddedTextures -v false;')
mel.eval("FBXExportSplitAnimationIntoTakes -clear;")
# Up Axis
mel.eval("FBXExportUpAxis z;")
# Export Animation from frame x to frame y
mel.eval('FBXExportSplitAnimationIntoTakes -v \"tata\" %d %d'%(int(startTime), int(endTime)))
mel.eval('FBXExport -f "%s" -s'%(fullName ) )

I appreciate your help! Have been working on this for a long time.

 

 

0 Likes