This topic explains how you can load a file from the disk and buffer memory.
The following code sample shows how to load a file from the disk using the FBApplication.FileOpen() function.
from pyfbsdk import * app = FBApplication() filename = r"C:\Program Files\Autodesk\MotionBuilder <year>\OpenRealitySDK\scenes\PlasticMan.fbx" # Open the sample file "PlasticMan.fbx", and prompt with a # UI dialog as indicated by the second True argument. app.FileOpen(filename, True)
To load data from the buffer memory, you must pass the raw address of the buffer memory to FBApplication.FileOpen() instead of a file name. The following code shows how to load data from the buffer memory using FBApplication.FileOpen().
from ctypes import * fbxfile = r"C:\Program Files\Autodesk\MotionBuilder <year>\OpenRealitySDK\scenes\PlasticMan.fbx" f = open(fbxfile, 'rb') buff = create_string_buffer(f.read()) f.close() FBApplication().FileOpen(addressof(buff), sizeof(buff)) # You can open this file from the memory as many times as you want.
You can use functions in the FBApplication class to control the data loaded from a file. The following table describes these functions.
Function | Description |
---|---|
FBApplication.FileOpen() | Opens a file, and replaces the current scene with the loaded data. This is equivalent to File |
FBApplication.FileMerge() | Opens a file, and merges the current scene with the loaded data. This is equivalent to File |
FBApplication.FileAppend() | Opens a file, and appends the loaded data to the current scene. This is equivalent to File |
FBApplication.FileImport() | Opens a file, and imports the animation data contained in the file. If the second parameter of this function is True, the animation data for the models matching the name in a scene is replaced by the imported data. This is equivalent to File |