Save Character Animation from python.

Save Character Animation from python.

Anonymous
Not applicable
1,302 Views
2 Replies
Message 1 of 3

Save Character Animation from python.

Anonymous
Not applicable

Hi,

 

I am trying to batch the "Save character Animation" menu action from python.

My Script is opening a list of files one after another and saving the character animation into a file.

 

I am using 

 

FBApplication().SaveCharacterRigAndAnimation(animPath, character, lFbxSaveOptions)

to save the animation. However, for some files, animation is not saving at all.

If I try to save animation from the file manually, it worked!

 

My code is something like below:

 

 for process in animFile:
        #Open animation file
        lFbxOptions = FBFbxOptions(False)
        FBApplication().FileOpen(process,False,lFbxOptions)
        
        lFbxSaveOptions = FBFbxOptions(False)
        lFbxSaveOptions.EmbedMedia = False
        lFbxSaveOptions.SaveCharacter = True
        lFbxSaveOptions.SaveControlSet = True
        lFbxSaveOptions.SaveCharacterExtension = True
        lFbxSaveOptions.FileFormatAndVersion = 
                            FBFileFormatAndVersion.kFBFBX2011
        
        CharCounter = 0
        for character in FBSystem().Scene.Characters:
            CharCounter = CharCounter + 1
            postFix = "_a_" + str(CharCounter) + ".fbx"
            
            animPath = intermediate + os.path.basename(process)
            animPath = animPath.replace(".fbx", postFix)
            
            FBApplication().SaveCharacterRigAndAnimation
                                (animPath, character, lFbxSaveOptions)

 

Can anyone give me any idea, what is the correct way to do it?

0 Likes
1,303 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
Is the file being generated and is empty, or is it not making the actual FBX at all?
0 Likes
Message 3 of 3

Anonymous
Not applicable

Hi Pixelord,

 

I don't know if it will fix the problem but, in FBX options the parameter should be set as True not False if you want to load a file.

 

for process in animFile:
        #Open animation file
        lFbxOptions = FBFbxOptions(False)

 

Cheers

0 Likes