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)
FBApplication.FileOpen()
. If you specify a relative path, it corresponds to the current working directory of MotionBuilder. You can change the current working directory in various ways. For example, by manually opening a file or invoking FBPopup.Execute()
to specify a location for saving or loading a file.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.