Notifications
Clear all

[Closed] Maxscript dynamic UI

Hi all, I was wondering if it’s possible to have a dynamically changing UI with maxscript?
The script I’m writing is related to renderers so I want to have a dropdown with Scanline, Vray and Mentalray listed. And when the dropdown is changed, I want the UI elements in the section below the dropdown to change accordingly. I know I can enable and disable elements quite easily and that method is my fallback plan if dynamic UI isn’t a possibility. So first of all, is this possible? And if it is, can someone point me in the direction of how I might start going about this?

Cheers,

Cg.

10 Replies

Time to grow to love the execute() function.

There’s a few thread on that in here, do a forum search.

http://forums.cgsociety.org/showthread.php?f=98&t=782510&highlight=dynamic+rollouts
(there’s one to get you started)

Yes. It’s possible. There are three ways how to do. It depends on what kind of window you have. If you have Dialog you can add and remove subrollouts. If you have RolloutFloater it’s better to add and remove rollouts.


try(destroydialog dRol) catch() 
rollout dRol "Dialog" height:200 width:200 
(
dropdownlist rolList "Rollouts: " items:#("Rollout A", "Rollout B", "Rollout C") width:175 offset:[0,0]
subrollout subrolls "" width:175 height:140
 
rollout rolA "Rollout A" height:160 width:120
(
checkbox lb "A"
)
rollout rolB "Rollout B" height:160 width:120
(
checkbox lb "B"
)
rollout rolC "Rollout C" height:160 width:120
(
checkbox lb "C"
)
 
local rolls = #(rolA, rolB, rolC)
on rolList selected sel do
(
if subrolls.rollouts.count > 0 and subrolls.rollouts[1] != rolls[sel] do removeSubRollout subrolls subrolls.rollouts[1]
addSubRollout subrolls rolls[sel]
)
)
createDialog dRol pos:[300, 200]
 
try(closerolloutfloater dRolFloater) catch() 
rollout rolA "Rollout A" height:160 width:120
(
checkbox lb "A"
)
rollout rolB "Rollout B" height:160 width:120
(
checkbox lb "B"
)
rollout rolC "Rollout C" height:160 width:120
(
checkbox lb "C"
)
rollout dRolF "Main Rollout" height:200 width:200 
(
dropdownlist rolList "Rollouts: " items:#("Rollout A", "Rollout B", "Rollout C") width:175 offset:[-6,0]
 
local rolls = #(rolA, rolB, rolC)
on rolList selected sel do
(
if dRolFloater.rollouts.count > 1 and dRolFloater.rollouts[2] != rolls[sel] do removeRollout dRolFloater.rollouts[2] dRolFloater
addRollout rolls[sel] dRolFloater
)
)
dRolFloater = newRolloutFloater "Floater" 200 200 300 450
addRollout dRolF dRolFloater

But I prefer to use third method. It’s to have whole set of controls and hide or unhide them depending on state of my tool.


try(destroydialog dRolH) catch() 
rollout dRolH "Dialog" height:200 width:200 
(
dropdownlist rolList "Rollouts: " items:#("Rollout A", "Rollout B", "Rollout C") width:175 offset:[0,0]
checkbox lbA "A" pos:[14,50] visible:off
checkbox lbB "B" pos:[14,50] visible:off 
checkbox lbC "C" pos:[14,50] visible:off
 
local rolls = #(#(lbA), #(lbB), #(lbC))
on rolList selected sel do
(
for k=1 to rolls.count do for c in rolls[k] do c.visible = (k == sel) 
)
)
createDialog dRolH pos:[740, 200]

In third case you don’t have to care about states of you controls (enabled, checked, value, etc.) as long as the dialog is open.

Thanks all. I think I like the sound of the 3rd option from Denis. I’ll give that a go first.

Cheers,

Cg.

 PEN

There is also rollout creator that you can rebuild the rollout and display it as you need it.

What about .NET Forms? You can add controls, events, etc at runtime. But mxs version has its limitations too.

Light

1 Reply
(@marcobrunetta)
Joined: 11 months ago

Posts: 0

According to Pete:
“This would probably be a flexible method, the flowlayout panel is good for this sort of thing”

Technically it’s not a problem to rebuild UI (there are some ways). Let’s talk about scripted plugin case… How can we newly created controls link to parameters in param blocks? There is no way! That’s the problem.

 PEN

Well you can fudge the connection to params. If you have a param you are likely to have a fixed UI item any ways. I have done it with call backs to update the UI how ever and it worked very well.

This project used all sorts of craziness like that…
http://www.paulneale.com/technical/pinkyDinkyDoo/pinkyDinkyDoo.htm

Ooh… yes. I have a lot of crazy stuff in my portfolio too. But I always look for most painless way… Only one thing I’d like to say – Don’t rebuild UI if it not really necessary!