Skip to content

Instantly share code, notes, and snippets.

@danielskovli
Last active February 16, 2021 04:37
Show Gist options
  • Save danielskovli/4c369d017a893f21705e33493ecb76f0 to your computer and use it in GitHub Desktop.
Save danielskovli/4c369d017a893f21705e33493ecb76f0 to your computer and use it in GitHub Desktop.
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