Python Reference Guide
 
Loading...
Searching...
No Matches
BasicOperations\FBSystemEvents.py
1# Copyright 2009 Autodesk, Inc. All rights reserved.
2# Use of this software is subject to the terms of the Autodesk license agreement
3# provided at the time of installation or download, or which otherwise accompanies
4# this software in either electronic or hard copy form.
5#
6# Script description:
7# Show how to register callback to FBSystem about global connections and data notification.
8# IMPORTANT: we need to remove these callbacks at the end of MoBu execution.
9#
10# Topic: FBSystem, FBApplication, FBSystem.OnConnectionNotify
11#
12
13from pyfbsdk import *
14
15def OnUIIdle(control, event):
16 print("UIIdle", control, event)
17
18def OnConnectionNotify(control, event):
19 """
20 FBEventConnectionNotify
21 FBConnectionAction Action : Connection's action performed.
22 int SrcIndex : Index of the source in the destination component.
23 FBConnectionType ConnectionType: Connection's type.
24 object SrcPlug : The source plug involved in the action.
25 object DstPlug : The destination plug involved in the action.
26 object NewPlug : New plug created by the action. (Mostly used by merge/replace)
27 """
28 print("OnConnectionNotify", event.Action, event.SrcIndex, event.ConnectionType, event.SrcPlug, event.DstPlug, event.NewPlug)
29
30def OnConnectionDataNotify(control, event):
31 """
32 FBEventConnectionDataNotify
33 FBConnectionAction Action : Connection's action performed.
34 object Plug : The plug involved in the action.
35 """
36 print("OnConnectionDataNotify", event.Action, event.Plug)
37
38def OnConnectionStateNotify(control, event):
39 """
40 FBEventConnectionStateNotify
41 FBConnectionAction Action : Connection's action performed.
42 object Plug : The plug involved in the action.
43 """
44 print("OnConnectionStateNotify", event.Action, event.Plug)
45
46def OnConnectionKeyingNotify(control, event):
47 print("OnConnectionKeyingNotify", event.Action, event.Plug)
48 print(event.StartTime.GetFrame())
49 print(event.StopTime.GetFrame())
50
51# This notification broadcasts a LOT of events!
52def Register():
53 #sys.OnUIIdle.Add(OnUIIdle)
54 sys.OnConnectionNotify.Add(OnConnectionNotify)
55 sys.OnConnectionDataNotify.Add(OnConnectionDataNotify)
56 sys.OnConnectionStateNotify.Add(OnConnectionStateNotify)
57 sys.OnConnectionKeyingNotify.Add(OnConnectionKeyingNotify)
58
59 # IMPORTANT: we need to remove all callbacks connected to FBSystem and FBApplication
60 # At file exit to avoid notification while the python environement is unitialized.
61 app.OnFileExit.Add(Unregister)
62
63def Unregister(control=None, event=None):
64 sys.OnConnectionNotify.Remove(OnConnectionNotify)
65 sys.OnConnectionDataNotify.Remove(OnConnectionDataNotify)
66 sys.OnConnectionStateNotify.Remove(OnConnectionStateNotify)
67 sys.OnConnectionKeyingNotify.Remove(OnConnectionKeyingNotify)
68 app.OnFileExit.Remove(Unregister)
69
70sys = FBSystem()
71app = FBApplication()
72Register()
73
FBApplication is used mainly to manage files.
Definition: pyfbsdk_generated.h:801
Provides access to the underlying system, and the MotionBuilder scene.
Definition: pyfbsdk_generated.h:18771