FBFbxOptions
can be used to specify the loading and saving behavior of FBApplication
. The constructor of FBFbxOptions
takes a boolean value as an argument to determine whether the instance will be used for saving or loading:
FBFbxOptions
- used to load scene data from a file.
FBFbxOptions
- used to save scene data to a file.
Scene elements such as characters, lights, cameras, textures, models, and constraints can be individually chosen to be saved, appended, merged or discarded during a saving or loading operation. The FBFbxOptions.Namespacelist
property allows you to change the namespace of the loaded scene elements. For example, the code sample below configures an FBFbxOptions
object to load only the materials from a file, and gives the loaded objects the "LOADED
" namespace.
from pyfbsdk import *
app = FBApplication()
# Clear the scene.
app.FileNew()
# Use the PlasticMan.fbx file.
filename = 'C:\Program Files\Autodesk\MotionBuilder <year>\OpenRealitySDK\scenes\PlasticMan.fbx'
# Create an FBFbxOptions object initialized to load data.
loadOptions = FBFbxOptions(True)
# Discard all the data in the file except for materials, which are appended
# into the current scene. The second parameter (False) of SetAll() ignores
# any animation data contained in the file.
loadOptions.SetAll(FBElementAction.kFBElementActionDiscard, False)
loadOptions.Materials = FBElementAction.kFBElementActionAppend
# Change the namespace of the loaded scene elements to "LOADED".
loadOptions.NamespaceList = 'LOADED'
# Open the file using these options. In the "Materials" section of the
# Navigator, observe that we only have the materials contained in the opened
# file.
#
# (!!!) Note: if the second parameter of FileOpen() is set to True, the
# namespace given in NamespaceList will be overridden and will not
# be applied.
app.FileOpen(filename, False, loadOptions)
The following table describes the possible values for FBPropertyElementAction
. These values are used to determine what to do with scene elements such as FBFbxOptions.Cameras
, FBFbxOptions.Lights
, FBFbxOptions.Materials
, etc.
The saving and loading of animation data can also be toggled through the use of several boolean (FBPropertyBool
) properties, including FBFbxOptions.CamerasAnimation
, FBFbxOptions.ModelsAnimation
, and FBFbxOptions.ActorFacesAnimation
.