[Closed] Earliest time to register MAXscript globals? [SDK]
Hello all,
I’m working on a renderer plugin that exposes a few different parameters as MAXscript globals, so a user can configure it through maxscipt like this:
myRender.option1 = 2
myRender.option2 = 1.5
Right now I register these global variables when my renderer is initialized, but this approach has a problem. If a user or script mistakenly tries to set one of these variables before selecting my renderer then they will instead be defining a new global variable sharing a name with one from the renderer. If they switch to my renderer after defining a variable like that it will make the renderer’s globals fail to register because their name is already in use.
To solve this I’d like to define my renderer’s globals as early as possible, preferably during Max initialization, to prevent the user from defining anything with the same name first. I tried registering my globals as soon as Max loads the plugin dll, but that just causes a crash on startup so i assume some MAXscript-related stuff is not initialized yet at that point.
So my questions is:
Is there some way I can get some of my code to run after Max is (almost) fully initialized, to avoid the above crash, but before the user has a chance to do anything?
i think you have to define your globals when the system loads your plugin. The name of your globals must be unique enough to not be overridden.
That is what I do now, but I’m specifically trying to correct the use case where a user mistakenly sets one of those variables before selecting the renderer. With my current setup that will put Max in a state where the only way to get the renderer MAXscript globals to work again is to restart Max, which is annoying and inconvenient.
Poking around the documentation some more I found that the answer to this is to make a GUP. This is a plugin class type that allows doing arbitrary things immediately after Max has loaded.
Is there something I’m missing about how to do that from other plugin types?
Renderer, modifier, object, utility, texture, etc plugins can only do something when they are explicitly created by the user. Without user interaction, I don’t see how these plugin types have the opportunity to do something immediately after max loads.
using function publishing any plugin can publish functions to mxs (or any other plugin ) available before any instance of the plugin is created.