Getting at MotionBuilder UI elements as FBVisualComponents



I’m looking to get existing MotionBuilder UI element’s as native types deriving from FBVisualComponent.

Specifically I’d like to hook into .OnChange of the Current Character Drop Down (Character Controls Window) to update the Current Character in a UI of my own. I’m able to get at the PySide QWidget for the drop down, but I’ve not found a way to get/cast to the native MotionBuilder type.

I know I can listen to something like system events instead, but it seems I would be looking though an an awful lot of events (with python on the main thread), so that deters me from going that route.

Hopefully this is all straight forward and I’m just being a tool!

Sune :):


Snippet to find the dropdown as a QWidget:

from PySide import QtCore, QtGui

#find the main window
parent = QtGui.QApplication.activeWindow()

while True:    
    parentWidget = parent.parentWidget()
    if parentWidget:
        parent = parentWidget
mainWin = parent

#Look thru all the QDockWidget to find the one with window title 'Character Controls'
for dockWidget in mainWin.findChildren(QtGui.QDockWidget):
    if dockWidget.windowTitle()=='Character Controls':
        characterCtrlWidget = dockWidget.widget()
#Find the current character dropdown
for widget in characterCtrlWidget.findChildren(QtGui.QWidget):
    if widget.accessibleName() == 'CharacterName':
        currentCharDropdown = widget