[Closed] Need Help: launching a script with file open
Hi,
I would like to know if it is possible to ‘embedd’ a scipt into a max file.
The idea beeing that the script would automatically launch when I open the max file.
(something like ScriptNode in Maya)
Is that possible ?
I looked around and did not find any relevant infos.
Thanks in advance for any help, tips…
it should be possible but not too easy if you don’t know maxscript.
one way that comes to my mind is adding the script as a pesistent event callback handler triggered after the file is opened.
for more info search the maxscript reference for “callback”.
Hey plastic,
thx for the answer,
Yeah i know a bit of maxscript,
going with callbacks seams a good idea, i’ll try that,
but it would do that for all files opened, right ?
There must be a simpler way to do this…
No. A persistent script living in a Max file would be launched only when the file it lives in is loaded.
If you want to run a script when ANY Max file is loaded, you would need a non-persistent callback script that is automatically started on Max startup (from Scripts/Startup for example)
From the Help:
“
[left]The optional persistent: parameter lets you control whether the script is saved permanently in the currently open scene file or is a global callback script that remains in place no matter what file opening and closing is performed. A true value for the parameter specifies that the script should be stored in the current file and loaded and registered for callback whenever that file is opened again. Persistent callback scripts are always removed when a new file is loaded or a reset is performed so that persistent scripts in one file don’t accidentally get copied to a later file. The default for this parameter is false, indicating the script is a global script and is not persistent.”
[/left]