[Closed] Max Script Beginner in need of help
Hi,
Does anybody know if there is a way to automatically make a script run when you open a specific max file? And then a way to stop it from running when that file is closed?
If not is there a way to check to make sure that an object either does or doesn’t exist? That way I can put my code inside an if statement that only runs if the objects that I know will be in the scene are actually there.
Thanks
to do such things there is General Event Callback Mechanism in MAX (see MXS Help).
You have to make a script which will set up some callbacks and put this script in …max…\scripts\startup\ folder.
To check that some file will be opened use #filePreOpenProcess.
To check that some file will be closed use #filePreOpenProcess, #systemPreNew, and #systemPreReset
If you need to check that some node was added do the scene you can use #objectXrefPostMerge and #sceneXrefPostMerge
See MXS help callbacks.addScript persistent: parameter how to use script of the currently open scene file.
Do not actually fully understand your idear .
There is a Startup folder inside maxroot\Scripts folder.
And there is many callbacks which may help you out of your problem.
It sounds like callbacks are what you want… basically you’ll want a file post open callback to see if it’s the file you want, and if so, run some code, if not, don’t. There are a few ways to check for specific objects (ie, by name, or by it’s unique node id), so it depends on what you specific need is.