[MotionBuilder] destroy tool event

mobu

#1

Hi,
This is my first post here. I created a simple tool in motion builder and hooked up a file event when the tool open up. That way if the user merge stuff or create a new scene the tool gets refreshed.

However I’d like to remove that file event upon closing the tool but I couldn’t find any infos regarding this matter.

Anyone got a clue? I’m sure someone already stumbled onto this. In max it’s fairly simple but I’ve got no clue on how to do this in MB

Regards,
f


#2

Quick update:

I tried using the OnUnbind event but closing the tool with the X doesn’t raise that event, it will only get raised when the tool gets destroyed ( FBDestroyToolByName )

Other solutions (work-around / hack )I thought was to remove the X from the window but didn’t find how to :confused:
or
Have the event registred once and check if the tool is open in the event and then do whatever is needed if the tool is open.

but… When I access the tool from the FBToolList and check if it’s visible I always get False even if it’s clearly visible


#3

So I tried to always add the callback when the tool open up and remove them before recreating them so I dont have any duplicate

but even the code from the documentaion generate duplicate
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."


app = FBApplication()
app.OnFileNew.RemoveAll()
app.OnFileNew.Remove(MyCallback)

app.OnFileNew.Add(MyCallback)

app.FileNew()

It seems like the RemoveAll() or Remove() arent working correctly :confused: