[Closed] Dynamic Rollout
hi guys.
I was wondering how to create some dynamic rollouts.
I’ve searched on this forum, and fund some threads like this one.
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
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 = “%”
” “Timmy” to:bob
(” is a literal ” and
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%
” 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.
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?
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
format "% % was an olympic % contestant in the % olympics." FirstName LastName Sport Year to:StringStreamVar
The % are like madlibs.
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
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
)
Hehe the only reason why I know the solution to that error message so easily is because I see it so often.
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.