[Closed] create RolloutFlouter with variable amount of Rollouts
When I run my script and the UI get’s generated I have a variable amount of sub-Rollouts I would like to generate from a predefined “template”
lets say the amount is 12 (because there are 5 rigged-thingies I would like to control – easy access to set key-frames on multiple controllers from this Rollout, etc…)
the “template” looks like this
Rollout ro001 "ro001"
(
checkbutton ro_001_cb01 "ro001_cb01"
pickbutton ro_001_pb01 "ro_001_pb01"
on ro_001_cb_01 changed state do updateButton
fn updateButton = (
print "touched"
print self.name
)
on ro001 rolledUp state do
if state then print "ro001 Rolled Down!" else print "ro001 Rolled Up!"
)
ideally I would like to create the Rollout based on a variable amount
I know the operator eval does not exist – but I am trying to find a way in maxscript that would be similar to how I would do it in another langusage
iTotal = 5 --or total in scene
for i=1 to iTotal do
(
Rollout eval(ro+(i)) ("ro"+i)
(
checkbutton eval(ro+(i)+"_cb01") ("ro"+i+"_cb01")
pickbutton eval(ro+(i)+"_pb01") ("ro"+i+"_pb01")
-- whish there was a this.
--on ro_001_cb_01 changed state do updateButton
fn updateButton = (
print "touched"
print self.name
)
on eval(ro+(i)) rolledUp state do
if state then print ("ro"+i+" Rolled Down!")
)
thanks
what are “other languages” that you are talking about? mxs has ‘execute’. it’s kinda the MEL’s ‘eval’. is it not good?
Hi denisT…
In ECMA-script based languages – specific ActionScript (AS3) – I was able to dynamically create ui-Objects and used eval to “cast” a dynamic build string (or from an array of strings) to the object identifier
I looked at execute – but my Rollout is much longer/complex than the example – It would contain 12 buttons, functions for each, local variables – to wrap all that in a string would be a huge ask. (e.g. 200 lines of code)
thanks
I am now looking at
rolloutCreator
as in
http://www.3dbuzz.com/forum/threads/132877-mass-create-ui-controls
e.g.
rci = rolloutCreator "Something" "Your Rollout" width:200 height:230
rci.begin()
for i=1 to 10 do
(
local nname = ("edit_"+ (i as string)) as name
rci.addControl #edittext nname "Test" paramStr:"text:\"Hello\""
)
CreateDialog (rci.end())
do you wanna know the truth? the rolloutCreator was written by poor mxs coders probably… and it sucks. do never use it and forget about its existence.
ok…?
What do you suggest then
I have multiple rollouts each with x-amount of buttons – all with the same functionality – except that they target different objects (e.g. a block with multiple point-helpers attached to it’s side as possible targets for link-controller – and then point-helpers themselves to be linked to some other world/object)
I would be great to have the buttons just visible in controller than to continuously switch between sub-object mode in motion-panel, etc…
I want to create generic Rollout – with generic array of toggle buttons
thanks
rolloutCreator only creates controls within a Rollout that is hard-coded by default
I want to create multiple Rollouts with their respective buttons and functions based on a integer variable to define their name
execute does seem the way to go – although:
- very cumbersome process to convert code into string
- Adds extra potential of mistakes by not including necessary /n line breaks and /”
- Makes code unreadable and difficult to debug
solution:
- could use a struct of some sort to encapsulate individual parts of the ui
- See if there is a OOP way subclassing individual parts
- use a parser to parse code-block to string for execute
- could use execute on Rollouts and rolloutCreator for child-controls
- Just cop it and do crazy deep-hierarchical-level clicking and frame-setting by hand
You can add and remove subRollouts from a rollout. you could just hide buttons and how them accordingly to what you need.
And off course .Net has tons of options and would be easier to deal with instead of subrollouts imo!