File Options
 
 
 

File Options

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:

Choosing Scene Elements

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.CustomImportNamespace 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 scene elements the "LOADED" namespace.

from pyfbsdk import *

app = FBApplication()

# Clear the scene.
app.FileNew()

# Use the PlasticMan.fbx file.
filename = "C:\Program Files\Autodesk\MotionBuilder 2012 (64-bit)\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.CustomImportNamespace = "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 CustomImportNamespace 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.

FBPropertyElementAction Description
FBElementAction.kFBElementActionSave

Save the element.

FBElementAction.kFBElementActionAppend

Append the elements to the current scene elements when loading or merging.

FBElementAction.kFBElementActionMerge

Merge the elements from the file in the currrent scene.

FBElementAction.kFBElementActionDiscard

Do not save or load this scene element.

Choosing Animation Data

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.