Notifications
Clear all

[Closed] callback functions

hi all,
i am trying to run some scripts when i am opening the max file ,i know that the “callback” functions does this thing,can anyone explain me file open callback function?
thanhs,
oviam.

6 Replies

Something like this should work:

callbacks.addScript #filePreOpen “YourFunction()” id:#MXSLoad

this adds the callback that will call YourFunction()

callbacks.removeScripts id:#MXSLoad
this removes the callback

Be careful so you don’t add 10 callbacks for the same things
good luck
/Andreas

hi andreas,
thanks for your reply, that function works fine but when i restart the max this callback script is not working
my script is something like this

“global YourFunction
fn YourFunction =(…)
callbacks.addScript #filePreOpen “YourFunction()” id:#MXSLoad

anywhere i am missing something?

thanks,
oviam.

1 Reply
(@bobo)
Joined: 11 months ago

Posts: 0

Where is the script saved? Does it auto-load when you restart max?

the script file is not saved anywhere, i am trying to save it in the scene file itself,so that i can do network rendering also, is it possible to do it in this way,or i have to put it in the startup script folder?

thanks,
oviam.

1 Reply
(@bobo)
Joined: 11 months ago

Posts: 0

You can make callbacks persistent, but #fliePreOpen might be a bad idea, as it would never be executed before the file it lives in is opened, it will be executed before the NEXT file is executed.
#filePostOpen might work that way though. See the persistent:true optional argument.

If persistent is false, the callback will live as global callback until you restart max. At that point, it would require a startup script to be launched again. If the callback is persistent, it will stick only to the file it was saved into, so opening a new file will remove the callback until you open its “host” file again.

thanks bobo, i will try that…

-oviam