Exporting only Selected items through python

Exporting only Selected items through python

addisonYMRCW
Explorer Explorer
1,213 Views
1 Reply
Message 1 of 2

Exporting only Selected items through python

addisonYMRCW
Explorer
Explorer

I've scoured the internet and these forums to no avail and hoping someone can help out.  I need to export only selected objects (both bones and mesh of certain items in a scene from a set).  I've found prior posts where people were using the FBFbxManager class to call "SaveSelected", but that's been deprecated and nothing else seems to give me what the menu "Save Selection" can do....

 

Any help would be awesome... as a point of reference I'm currently using FBFbxOptions to set a dialog and a bunch of other things before running FBApplication().FileSave

0 Likes
1,214 Views
1 Reply
Reply (1)
Message 2 of 2

jps
Advocate
Advocate

Not sure how you are setting you fboptions but it might come from there.

Here is an example of how to use it and a test script that works in MB2019.

 

gFileFormat = FBFileFormatAndVersion.kFBFBX2011           # chose your FBX version (in this example FBX 2011, default is kFBDefaultFormatAndVersion )

saveSelectedOptions = FBFbxOptions(False)

saveSelectedOptions.FileFormatAndVersion = gFileFormat            # set your FBX version

saveSelectedOptions.SetAll(FBElementAction.kFBElementActionDiscard, False)             # disable all element to save

saveSelectedOptions.EmbedMedia = False              # disable export media

saveSelectedOptions.Bones = FBElementAction.kFBElementActionSave               # enable bones

saveSelectedOptions.BonesAnimation = True               # enable bones animation

saveSelectedOptions.Models = FBElementAction.kFBElementActionSave               # enable models (Markers, nulls, meshes)

saveSelectedOptions.ModelsAnimation = True               # enable models animation

saveSelectedOptions.Materials = FBElementAction.kFBElementActionSave               # enable material

saveSelectedOptions.SaveSelectedModelsOnly = True               # set save selected elements only

Then use 

FBApplication().FileSave(fbxFileToExport, saveSelectedOptions)

 

That should work

 

Try the script and tell me if you have any success.

0 Likes