View Full Version : How to recall previous changes in rollout parameters ?
01-21-2008, 05:41 AM
I have a rollout in a scripted simpleObject plugin with spinners set to default values.
I want the plugin to retrieve the last changes for each new object I create.
For example, I have a Segments parameter set to 1 by default. If I set it to 3 for the first object I create, I want the Segments value to remain set to 3 the next time I run the script (in the same session).
In the User Reference, I have found this in Scripted Plug-in Clauses:
parameters <name> [type:#class] [rollout:<name>]
The optional type:#class specifies that the parameters in the parameter block are "class" parameters. This means that there is one copy of each parameter for the *all* the objects of this plug-in class; they all share the parameter. Examples of existing class parameters are the creation type and type-in parameters in a typical geometry primitive.
The description fits exactly what I'm looking for but I cannot make it work. With type:#class added, the default values in the Parameters block are ignored and set to 0.
Please can anyone help me? Thanks in advance.
01-22-2008, 03:43 AM
Ok. I guess I'm completely missing some important point here. Isn't that feature widely used when implementing rollouts in your scripts?
Imagine that you have to create 20 boxes with different dimensions but the same number of segments. Then you'd have to re-enter the segments values 20 times.
Or you want to create 20 different cylinders using the Edge method. For each new cylinder, you'd have to : exit creation mode, go back to creation mode, click the Edge radio button again, all this 20 times!
If there is another way than the type:#class in the parameter block definition, could someone at least point me in the right direction? Many many thanks!
01-22-2008, 07:03 PM
I don't know if there's another way to handle this i'm sure someone will have a better suggestion. But i would on close write the settings of all spinners or what not to a ini file i had created in hte script root or somewhere else, then on loading the rollout just set the values of the spinners to the ones stored in there.
01-22-2008, 09:24 PM
I don't know if there's another way to handle this i'm sure someone will have a better suggestion. But i would on close write the settings of all spinners or what not to a ini file i had created in hte script root or somewhere else, then on loading the rollout just set the values of the spinners to the ones stored in there.That's a good idea if you want to retain the values between instances of max. If you only want the values to be maintained within the current instance max you will need to create a global variable to maintain the information as the data in the plugin is recreated each time you open the rollout.
01-23-2008, 04:14 AM
Jsnyder and RustyKnight, thank you for your replies.
The .ini file seems a good idea, exept that if I create one for each scripted plug-in, that could make a lot of .ini files in the end.
I've made several tries with a global and can't make it work. Here is one of them:
plugin simpleObject primDisk
category: "Custom Primitives"
parameters prmCreatMeth rollout:rltCreatMeth
creatMeth type:#integer ui:creatMeth default:2
rollout rltCreatMeth "Creation Method" width:162 height:26
radiobuttons creatMeth "" pos:[15,5] height:15 labels:#("Edge", "Center") default:2
on creatMeth changed do
primDisk_creatMeth = creatMeth
on buildMesh do
if primDisk_creatMeth != undefined do
if creatMeth != primDisk_creatMeth do
creatMeth = primDisk_creatMeth
. . . . .
If I declare the global at the beginning of the plugin, it says "plug-in clause expected". So I put it in the rollout.
If I do the test in the rollout, it says "rollout clause expected" (lol), so I put it in the buildMesh.
Now when I try to create the object with the mouse, it doesn't work and both radio buttons are blank. I added "print creatMeth" just before the test and the listener shows 2 (which is good) followed by 0. I can't figure how creatMeth is set to 0.
So I didn't even get a chance to test if the value is retrieved from one instance to another. Maddening. : /
And I'm still wondering why the type:#class thing is not correctly documented.
Bobo, if you can spare a little time, could you shed some light, please?
01-23-2008, 05:43 AM
Try and declare the global variable outside the context of the plugin...
01-23-2008, 06:27 AM
Oh, ok. I didn't know you could put expressions outside the plugin block.
I added a "print primDisk_creatMeth" (the global) just before the test in the buidmesh and it returned 0 instead of undefined. So the first test was wrong and the script was going in endless circles, copying each variable into the other. Hence the blank radio buttons.
So I changed the test to if primDisk_creatMeth == 0 doand it's MUCH better. Now if I change the creation mode, it remains changed for the next disk I draw. Great!
Two things, though:
1- having the global return 0 is fine for a radioButtons control. It might cause problems with another control holding a float (for 0 or any other value). Can I initialize it to undefined, or a character? And then use it to hold a number?
2- the script works if I create several disks in a row. If I exit the plugin and come back to it, it's back to default again. I tried to make the global's declaration conditional but it's the same. I suppose the global disappears from memory when I end the plugin.
Could you think of a walkaround for these two points?
Why not use ini files? Then you can keep track of your settings the whole session or even all following sessions...
Lookup inisettings in the helpfile, they are way easy, and don't require another global var.
01-23-2008, 07:48 AM
Well, after messing with that global, the .ini file option seems a pretty good idea.
When you say:
Then you can keep track of your settings the whole session or even all following sessions... do you mean I can choose one way or the other?
I'd like to retrieve the previous settings only if I'm in the same session and still get the default values when I start max. Is there a way to detect if the plugin is launched for the first time in a max session?
I'm really trying to have that plug-in behave like a Standard Primitive. I cannot describe it better.
01-23-2008, 07:48 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2014, Jelsoft Enterprises Ltd.