PDA

View Full Version : Dynamic Rollout


holycause
08-19-2008, 06:02 PM
hi guys.
I was wondering how to create some dynamic rollouts.

I've searched on this forum, and fund some threads like this one (http://forums.cgsociety.org/showthread.php?f=98&t=497862&highlight=dynamic+rollout).

but can't understand how the stringStream is really working :S

I looking to add a specific rollout depending the $ classof. and destroy it if nothing is selected

thatoneguy
08-19-2008, 06:17 PM
What you do is create a rollout normally and then just put it into quotation marks. (Using \"\" for literal quotes, \\ for slash etc.) Just treating it like a string.


bob = "" as stringstream

is really just a fancy string.

then you add stuff to it.

format "jim = \"%\"\n" "Timmy" to:bob

(\" is a literal " and \n literal "new line". The % means put a variable in this place.)

The output of that would be the equivalent to:

jim = "Timmy"

then you execute your string when the code is done:

execute bob. And it's like using a "filein" script only from a string.

This'll now define a variable.

If you want a rollout you create the rollout say

for i = 1 to 100 format "Rollout Box%" i to:AStringStream
etc etc...

you would now have 100 rollouts whose name formatting you know.

AddSS = "" as stringstream
for i = 1 to 100 do
(
format "AddSubRollout Rollout Box%\n" i to:AddSS
)
execute AddSS

It's just creating code dynamically. Nothing particularly fancy. So the easiest way is to write the code once. And then write a function which batch "writes" code.

holycause
08-19-2008, 07:01 PM
ok, thx for ur explanations

But why is he using 5 time i in his script

") i i i i i to:codestream
format "AddSubRollout PFManagerRollout.op BirthOp%" i to:codestream

what does it mean?

xenry
08-19-2008, 07:17 PM
because between the quotes ( format " ..... " ) there are 5 '%' symbols, and every 'i' comes in place (e.g. substitutes) one of those '%' .

btw. you can use the built-in RolloutCreator struct to generate dynamic rollouts. Do a quick search in the reference

holycause
08-19-2008, 07:58 PM
i know the the rolloutcreator.

but i think this way is better

thatoneguy
08-20-2008, 08:31 AM
format "% % was an olympic % contestant in the % olympics." FirstName LastName Sport Year to:StringStreamVar

The % are like madlibs.

holycause
08-20-2008, 06:44 PM
it's working fine.

Thx to all of u for ur help.

Btw, if i change this

Rollout test to global te = test ...... ("Rollout % ........ ") te ... to codestream I got an error message like this one: >> MAXScript Rollout Handler Exception: -- Cannot assign to read-only variable: undefined <<


because i really would like to use the % for the rollout name

thatoneguy
08-20-2008, 07:30 PM
The problem is you're trying to call your rollout "Undefined"

Global testRollout = test

format ("Rollout % ...) "test" to:codestream

Test needs to be a string not a variable.


The advantage of this is you can do something like:

for o in objects do
(
format ("Rollout %") o.name to:stringstream
)

holycause
08-20-2008, 07:33 PM
i m so stupid sometimes. :banghead:

thx a lot

thatoneguy
08-20-2008, 08:00 PM
Hehe the only reason why I know the solution to that error message so easily is because I see it so often. :D

I actually happen to be rewriting the script that my example was based on right now... I wish I had time to go back and rewrite the generic example. I found some much better ways of handling the rollout spinner.

CGTalk Moderation
08-20-2008, 08:00 PM
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.