Notifications
Clear all

[Closed] Reusing rollout in subrollout in same dialog

rollout rola "rol a" (
	label lbl "ROLLOUT A"
)
rollout rolb "rol b" (
	label lbl "ROLLOUT B"
	subrollout subrolb1 "B sub"  height:50
	on dlgRol open do (
		addSUbrollout  subrol1 rola
	)	
)
rollout dlgRol "dialog" (
	label dlgLbl "DIALOG" 
	subrollout subrol1 "sub1"  height:200
	on dlgRol open do (
		addSUbrollout  subrol1 rola
		addSUbrollout  subrol1 rolb
	)
)
createdialog dlgRol height:220

So… I have 2 rollout definition.
I want to reuse rola in subrollour of rolb.
I need to show rola and rolb at the same time.

Looks like maxscript doesn’t like this,
Any solution?

10 Replies

After many experiments, I decided not to use the SubRollout solutions in my interfaces.
Sometimes I use the Rollout Floater, but usually when I need multiple rollouts I try to organize dialog with using the Tab controls (which means one Rollout, but hides/shows specific parts of it depending on the particular mode).

 MZ1

The problem is you cannot create a instance of a rollout without redefining it. Some tricks may help you, for example saving rollout definition string and re executed it again.

here i show how easy to organize “rollout definition” for multiple rollout instances use

ac = attributes ac
(
	parameters params 
	(
	)
	-- rollout def:(
	rollout d "The A"
	(
		spinner sp "Value: " 
	)
)

fn createRollout ca_def = 
(
	ss = stringstream (custattributes.getdefsource ca_def)	
	seek ss 0
	skiptostring ss "-- rollout def:"
	d = execute ss
	free ss
	d 
)

rollout dialog "dialog" 
(
	subrollout subrol "subs"  height:200
	on dialog open do 
	(
		for k=1 to 3 do
		(
			d = createRollout ac
			addsubrollout subrol d
		)
	)
)
createdialog dialog height:220 

as you can see it’s much easier to edit the real mxs code to extend the ‘rollout definition’ code

you can see that attribute’s rollout definition is almost unlimited by its content. so it’s usually enough to define any simple rollout.

Wow… u r true genius.
My rollout is pretty complicated with 600ish line.
But, i’ll try.

THANKS!

 MZ1

brilliant!

Is there ny difference between
d = execute ss
d = readvalue ss
d = readexpr ss
?
All seem to work as expected.

Have a FUN!

(	
	try destroyDialog ::dialog catch()
	
  	rollout dialog "Test Sub Rollouts" width:200
  	(
		local ca_def = attributes ca_def 
		(
			parameters params rollout:params
			(
				value type:#integer default:1 ui:ui_value 
				number type:#integer default:1 ui:ui_number
			)
			rollout params "A"
			(
				dropdownlist ui_number items:#("- 1 -", "- 2 -", "- 3 -", "- 4 -") 
				spinner ui_value "Value: " type:#integer fieldwidth:54 offset:[0,6]
			)
			fn getRollout = this.params
		)
		local cb_def = attributes cb_def 
		(
			parameters params rollout:params
			(
				value type:#integer default:2 ui:ui_value 
				number type:#integer default:1 ui:ui_number
			)
			rollout params "B"
			(
				spinner ui_value "Value: " type:#integer fieldwidth:54
				radiobuttons ui_number labels:#("1", "2", "3") columns:3 offset:[0,6]
			)
			fn getRollout = this.params
		)
		local cc_def = attributes cc_def 
		(
			parameters params rollout:params
			(
				value type:#integer default:3 ui:ui_value 
			)
			rollout params "C"
			(
				spinner ui_value "Value: " type:#integer fieldwidth:54
			)
			fn getRollout = this.params
		)
		
		local _ca = createinstance ca_def
		local _cb = createinstance cb_def
		local _cc = createinstance cc_def
		
		local attrs = #(_ca, _cb, _cc)
		
		subrollout subs_sr "" width:180 height:300
		button test_bt "Set Rollouts" width:180 offset:[0,8] 

		fn clearSubRollouts = 
		(
			while subs_sr.rollouts.count > 0 do removeSubRollout subs_sr subs_sr.rollouts[1]
		)
		
		local WM_SETREDRAW = 0xB
		
		on test_bt pressed do
		(
			windows.sendMessage subs_sr.hwnd[1] WM_SETREDRAW 0 0
			
			clearSubRollouts()			
			for k=1 to 3 do 
			(
				ca = attrs[random 1 3]
				addSubRollout subs_sr (ca.getrollout())
			)
			
			windows.sendMessage subs_sr.hwnd[1] WM_SETREDRAW 1 0
			subs_sr.pos = subs_sr.pos
		)
		
		on dialog open do
		(
			for ca in attrs do addSubRollout subs_sr (ca.getrollout())
		)
  	)
  
  	createDialog dialog
)

Now let’s change the task… Populate by different rollouts with the same definition:

(	
	try destroyDialog ::dialog catch()
	
  	rollout dialog "Test Sub Rollouts" width:200
  	(
		local ca_def = attributes ca_def 
		(
			parameters params rollout:params
			(
				title type:#string
				value type:#integer default:1 ui:ui_value 
				number type:#integer default:1 ui:ui_number
			)
			rollout params title
			(
				dropdownlist ui_number items:#("- 1 -", "- 2 -", "- 3 -", "- 4 -") 
				spinner ui_value "Value: " type:#integer fieldwidth:54 offset:[0,6]
			)
			fn getRollout = this.params
		)

		local _ca = createinstance (execute (custattributes.getdefsource ca_def)) title:"A0"
		local _cb = createinstance (execute (custattributes.getdefsource ca_def)) title:"A1"
		local _cc = createinstance (execute (custattributes.getdefsource ca_def)) title:"A2"
		
		local attrs = #(_ca, _cb, _cc)
		
		subrollout subs_sr "" width:180 height:300
		button test_bt "Set Rollouts" width:180 offset:[0,8] 

		fn clearSubRollouts = 
		(
			while subs_sr.rollouts.count > 0 do removeSubRollout subs_sr subs_sr.rollouts[1]
		)
		
		local WM_SETREDRAW = 0xB
		
		on test_bt pressed do
		(
			windows.sendMessage subs_sr.hwnd[1] WM_SETREDRAW 0 0
			
			clearSubRollouts()			
			for k=1 to 3 do 
			(
				ca = attrs[random 1 3]
				addSubRollout subs_sr (ca.getrollout())
			)
			
			windows.sendMessage subs_sr.hwnd[1] WM_SETREDRAW 1 0
			subs_sr.pos = subs_sr.pos
		)
		
		on dialog open do
		(
			for ca in attrs do addSubRollout subs_sr (ca.getrollout())
		)
  	)
  
  	createDialog dialog
)

they all also have a different title

Page 1 / 2