Notifications
Clear all

[Closed] Rollout Creator Dynamic codeStr??

Hello fellow Desingvelopers,

I have a simple but for me important question. On searching I couldn’t find the answer or I wasn’t able to absorb the right information.

Here is my question:

I’m coding with MaxScript and encountered a problem when creating Dynamic Rollouts.

I want to create Subrollouts with a for-loop consisting of Rollouts created with the rolloutCreator functions.

this is my code:

fn function_pointer=
(
	rollout test "test" width:400 height:400
	(
		subRollout test1 "test1" pos:[0,0] width:400 height:(400)
	)
	
	createDialog test
	
	for i in 1 to edge_Counter do
	(
		rci = rolloutCreator (("point_"+(i as string)) as name) ("Point "+(i as string)) width:400 height:(400)
		rci.begin()

		rci.addControl #spinner (("x"+(i as string)) as name) ("X "+(i as string)) paramStr:"range:[0,50000,0]"
		rci.addControl #spinner (("y"+(i as string)) as name) ("Y "+(i as string)) paramStr:"range:[0,50000,0]"

		rci.addControl #button (("set"+(i as string)) as name) ("Set "+(i as string))
			
			
		rci.addHandler (("set"+(i as string)) as name) #pressed filter:on codeStr:"layouter point_i_Counter ((@x@+(point_i_Counter as string))).value ((@y@+(point_i_Counter as string))).value"
			
		rci.end()
			
		append array_Rollouts rci.def
		
		addSubRollout test.test1 array_Rollouts[i] rolledUp:on
	)
)

So the main aim of this Dynamic Rollout is after pressing the set(i) button the call of the function “layouter” fed with 3 values: [B]1./B 2.x(i).value 3.y(i).value

I’m encountering actually 2 Problems:

  1. I cant access the according y(i) / x(i) values and
  2. the variable point_i_Counter is always==edge_Counter.

I hope you can help me in any way.

Greetings
Jan

6 Replies

rollout test "test" width:400 height:400
(
	fn function_pointer edge_Count=
	(
		local array_Rollouts = #();
		
		for i = 1 to edge_Count do
		(
			local rci = rolloutCreator ("point_"+i as string) ("Point "+i as string) width:400 height:400
			rci.begin()
			
			rci.addControl #spinner ("x"+i as string) ("X "+i as string) paramStr:"range:[0,50000,0]"
			rci.addControl #spinner ("y"+i as string) ("Y "+i as string) paramStr:"range:[0,50000,0]"
			
			rci.addControl #button ("set"+i as string) ("Set "+i as string)
			
			
			rci.addHandler ("set"+i as string) #pressed filter:on codeStr:(@"format @% %
@ "+ ("x"+i as string) +".value "+ ("y"+i as string) +".value")
			
			rci.end()
			
			append array_Rollouts rci.def
		)
		return array_Rollouts;
	)

	subRollout test1 "test1" pos:[0,0] width:400 height:400
	
	on test open do 
	(
		for ro in function_pointer 5 do
			addSubRollout test1 ro rolledUp:true
	)
)
	
createDialog test

how about something along these lines?

Thank you very much that seems to be a very good starter!

can you tell me what this is doing?:

@”format @% %
@

greetings
Jan

click the button and have a look in the listener (F11) and you’ll see

format is a modularly overloaded string method that replaces the % chars with the supplied i=2++ values
the @ in front of the string makes it a verbatim string so the
(newLine char) isn’t evaluated in the scope of the codeSTR property bracket

Okay the Button prints the specified x and y values into the console. Thats great! But I really cant figure out how to use the values for example to feed a function.

I mean can you give me an example where the pressing on the button starts a function that is only fed with the according x(i) value?

thanks alot

For example I’m using your code and changed some things

local rci = rolloutCreator ("point_"+i as string) ("Point "+i as string) width:400 height:400
			rci.begin()
			
			rci.addControl #spinner ("x"+i as string) ("X "+i as string) paramStr:"range:[0,50000,0]"
			rci.addControl #spinner ("y"+i as string) ("Y "+i as string) paramStr:"range:[0,50000,0]"
			rci.addLocal ("point_i" as string) init:i
			
			rci.addControl #button ("set"+i as string) ("Set "+i as string)
			
			
			rci.addHandler ("set"+i as string) #pressed filter:on codeStr: "print point_i; print x1.value; print (@x@+(point_i as string)).value"

the Output window says this:

1
0.0
-- Error occurred in set1.pressed()
--  Frame:
>> MAXScript Rollout Handler Exception:
-- Unknown property: "value" in "x1" <<

So its getting everything… its getting the local variable point_i according to the set button, its getting the x1.value… but when I write to get the point_i according x value it doesnt work…


	fn something x y =
	(
		print (x as string + y as string)
	)

	fn function_pointer edge_Count=
	(
		local array_Rollouts = #();
		
		for i = 1 to edge_Count do
		(
			local rci = rolloutCreator ("point_"+i as string) ("Point "+i as string) width:400 height:400
			rci.begin()
			
			rci.addControl #spinner ("x"+i as string) ("X "+i as string) paramStr:"range:[0,50000,0]"
			rci.addControl #spinner ("y"+i as string) ("Y "+i as string) paramStr:"range:[0,50000,0]"
			
			rci.addControl #button ("set"+i as string) ("Set "+i as string)
			
			
			rci.addHandler ("set"+i as string) #pressed filter:on codeStr:(@"something "+ ("x"+i as string) +".value "+ ("y"+i as string) +".value")
			
			rci.end()
			
			append array_Rollouts rci.def
		)
		return array_Rollouts;
	)