Earliest time to register MAXscript globals? [SDK]

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Search this Thread Display Modes
  11 November 2017
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?
  11 November 2017
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.
  11 November 2017
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.
  11 November 2017
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.
  11 November 2017
... as any other plugin including scripted plugins
  11 November 2017
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.
  11 November 2017
using function publishing any plugin can publish functions to mxs (or any other plugin ) available before any instance of the plugin is created.
  11 November 2017
... and define any system global as well
reply share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 12:39 AM.

Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.