Last active
February 16, 2021 04:37
-
-
Save danielskovli/4c369d017a893f21705e33493ecb76f0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pyfbsdk import * | |
def getSelectedObjects(): | |
'''Grab scene selection here and update UI/whatever''' | |
pass | |
def OnConnectionStateNotify(control, event): | |
'''Callback for all scene `ConnectionState` changes. Capture (un)select and process''' | |
if not event.Action in (FBConnectionAction.kFBSelect, FBConnectionAction.kFBUnselect): | |
return | |
getSelectedObjects() | |
def Register(): | |
'''Register callbacks and future destruction''' | |
FBSystem().OnConnectionStateNotify.Add(OnConnectionStateNotify) | |
# Remove all callbacks on shutdown | |
FBApplication().OnFileExit.Add(Unregister) | |
# FBApplication().OnFileNew.Add(Unregister) # temp, for testing | |
def Unregister(control=None, event=None): | |
'''Unregsiter callbacks''' | |
FBSystem().OnConnectionStateNotify.Remove(OnConnectionStateNotify) | |
FBApplication().OnFileExit.Remove(Unregister) | |
Register() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment