File Events

File Events

FBApplication allows for various callback functions to be registered to file I/O events. The code sample below illustrates how to register a function to be called just before the scene is cleared from FBApplication.FileNew()'s execution.

from pyfbsdk import *

def MyCallback(pCaller, pEvent):
    ''' 
    pCaller: In this example, it will be the FBApplication object.
    pEvent:  An instance of the FBEvent triggered.
    '''
    print "MyCallback Triggered."


# Get the instance of FBApplication.
app = FBApplication()

# Register the callback function to the OnFileNew event.
app.OnFileNew.Add(MyCallback)

# Create a new scene. This triggers the OnFileNew event.
app.FileNew()

# Remove the callback function we have created when we are done.
app.OnFileNew.Remove(MyCallback)
Note: All the callbacks of an event may be removed in one call, for example: app.OnFileNew.RemoveAll()

Event Descriptions

The following table describes the events which are triggered by FBApplication.

EventDescription
FBApplication.OnFileNewTriggered when FBApplication.FileNew() is invoked, but before anything has been destroyed.
FBApplication.OnFileNewCompletedTriggered when FBApplication.FileNew() has completed.
FBApplication.OnFileOpenTriggered when FBApplication.FileOpen() is invoked, but nothing has been loaded yet.
FBApplication.OnFileMergeTriggered when either of the following functions have been invoked, but before anything is loaded:
  • FBApplication.FileMerge()
  • FBApplication.FileAppend()
FBApplication.OnFileOpenCompletedTriggered when either of the following functions have completed their execution:
  • FBApplication.FileOpen()
  • FBApplication.FileMerge()
  • FBApplication.FileAppend()
FBApplication.OnFileSaveTriggered when FBApplication.FileSave() has been invoked, but before anything is saved.
FBApplication.OnFileSaveCompletedTriggered when FBApplication.FileSave() has completed.
FBApplication.OnFileExitTriggered when FBApplication.FileExit() is invoked.