PDA

View Full Version : Opening and closing rollouts


Alex Morris
06-10-2003, 10:59 AM
Hi guys,

Whats the best way of handling this in a floater with multiple rollouts?

I've attached a test file which illustrates the problem. It tries to access the rolledUp property of the second rollout before it is defined.

Is there a preferred way of dealing with this for say 5-6 rollouts in a floater - ie. a scalable solution - which steps through each rollout opening and closing them one at a time?

When is it better to just open new floaters rather than rollouts?

Baldrick
06-10-2003, 12:51 PM
Simple modifcation to get your script to work - declare your second rollout as a global at the start of your script by adding this line at the top;
global r2

Unfortunately, I don't think there is any 'generic' way to do this without hard coding it all because you need to know the rollout object names and I don't think you can get those via MAXScript if don't already know them...

magicm
06-10-2003, 12:52 PM
The script you attached executes without problems on my computer..

What you might want to do, is to declare each rollout at the top of your script, like this:


-- start local scope. this is needed to be able to define local variables
(

-- declare rollout variables
local r1, r2

-- start of your script..
rollout r1 "r1" width:160 height:40
..
..
..
nr = newRolloutFloater "Test" 172 100
addRollout r1 nr
addRollout r2 nr rolledup:true
-- end of your script..

)-- end local scope


good luck ;)



Like Baldrick said, using globals is also an option, but personally I tend to avoid them. just to keep things nice and clean

Alex Morris
06-10-2003, 05:36 PM
thanks guys

I'll give that a whirl - probably using locals
Any ideas on swapping out rollout interactively?

magicm
06-10-2003, 09:07 PM
Originally posted by Alex Morris
Any ideas on swapping out rollout interactively?

AFAIK.. not possible unless you create the rollouts dynamically (using strings and the <b>execute</b> function).. There's also a script that lets you create rollouts dynamically, which can be found in:

3dsmax5\stdplugs\stdscripts\baseLib\rolloutCreator.ms..

Another thing that pops to mind; you possibly could use the removeRollout[b] / [b]addRollout functions to close rollouts and put them back again in a specific order.. not sure if this works though

Kramsurfer
06-11-2003, 03:24 PM
yeah,

removeRollout Rolloutname RolloutFloatername

You need to remove all the rollouts below the one you are changing the then add them again.

If you've three Rollouts on one floater

ROF= newRolloutFloater "Test" 200 200
addRollout Rolly01 ROF
addRollout Rolly02 ROF
addRollout Rolly03 ROF

Add you want to change / Replace Rolly02 then you need to

removeRollout Rolly03 ROF
removeRollout Rolly02 ROF
addRollout Rolly02Different ROF
addRollout Rolly03 ROF

Creating them dynamically is well worth the effort to learn and it's not that hard. Then your controls can be tied to any set of data.

Something like:

myName = #("Bone", "Control", "Dummy","fool", "work","Silly")
RolloutString= "\nrollout ss_roll \"Test Checkboxs \"\n(\n"
for i = 1 to MyName.count do
(
RolloutString=RolloutString +("checkbox " + myname[i] + "_enabled " + "\"" + myname[i] + "\"\n")
)
RolloutString=RolloutString+")\n"
format "%\n" RolloutString
execute RolloutString

When the execute command runs it evaluates the string as if it where maxscript you had created and ss_roll becomes a valid Rollout value. This rollout does little more than create checkbox's however. You would create a second loop to write the part of the rollout that would add functionality to the checkboxs. the format command in there will let you "see" the rollout before it's executed. I develop the rollout with just the format command so it just prints in the listener. When it looks good in the listener, then dash out the format and go for the execute command.

Good Luck

Keith Morrison

CGTalk Moderation
01-15-2006, 09:00 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.