PDA

View Full Version : New subrollout when a button is pressed


mhdmhd
05-24-2011, 05:51 PM
How can I add a new subrollout to a rollout every time I press a button in the same rollout?
The variable of the subrollout is the same in the button's event,how can I change it based on picked object for example ?

I have searched the forums,and found about execute but when I execute the name of the object it outputs the name of the object as a string naturally .

It would be easier if there is obj.name as variable:applause: just kidding.

I forget to mention that it is for a custom attributes modifier and not a floater.

plastic
05-24-2011, 06:11 PM
check out rolloutCreator in the maxscript reference.

I'm not sure if this direct link works:

http://docs.autodesk.com/3DSMAX/14/ENU/MAXScript%20Help%202012/index.html?url=files/GUID-5FC5036F-E2D7-46C9-9AFA-7B3550B9F25-1888.htm,topicNumber=d28e644885

mhdmhd
05-25-2011, 01:49 AM
I want to make a space switch ui for my custom rig when I pick the object it creats a slider to control the weight of some controllers,How do I do this?

denisT
05-25-2011, 02:56 AM
I want to make a space switch ui for my custom rig when I pick the object it creats a slider to control the weight of some controllers,How do I do this?
show us how you tried to do this.

mhdmhd
05-25-2011, 12:52 PM
This is how I tried to do it:
parameters SpcP rollout:SpaceRollout
(
SpcBlnd type:#float ui:MnSpc default:0
objs type:#maxobjecttab tabSizeVariable:true
)
rollout SpaceRollout "SpaceSwitches" width:168 height:550
(
Slider MnSpc "Free/Locked" type:#float range:[0,1,0]
pickbutton AdBtn "Add Object" width:140 height:35
subrollout SbRollout "SbSwitches" width:130 height:200


on AdBtn picked obj do
(
pkobj=nodeTransformMonitor node:obj forwardTransformChangeMsgs:false
append objs pkobj

(
rollout rol1 obj.name
(
slider sld1 "blend:"
)
addSubRollout SbRollout Rol1

/* rci = rolloutCreator obj.name obj.name
rci.begin()
rci.addControl #slider #sld1 "blend:"
rci.end()
addSubRollout SbRollout rci .def */
)
)
)

But then I realized that it won't stay because every time the rollout is created after selecting, it evaluates the original ui without these sliders and it is not practical to put the whole custom attributes (very large) into the button' event, isn't it?

I thought I could put new modifier with every object added instead, that also allows me to delete it.

hlapecjernej
06-22-2011, 11:22 PM
if i understand your problem right, you need a system to dinamicaly load parameters.
The way i went about it, when i had a similar problem, was to write controls as text stream and then, at a conveniant moment, run it, using "execute" command.
example:

aFloater = newRolloutFloater "Renamer" 300 360
rollout foo "Starter" (
button foo_btn "Get selection names"
subrollout foo_sub width:280

on foo_btn pressed do (
local txt = "rollout foon \"Foo names:\" width:270 (\n"
for i = 1 to selection.count do (
txt += "edittext sel" + i as string + " text:\"" + $[i].name + "\" width:220 align:#right\n"
)
for j = 1 to selection.count do (
txt += "on sel" + j as string + " entered nn do ($[" + j as string + "].name = nn)\n" --; foo.foon.sel" + i + ".text =
)
txt += ")\n"
txt += "AddSubRollout foo.foo_sub foon\n"
execute txt
foo.height = selection.count*30
foo.foo_sub.height = selection.count*30
)
)
addRollout foo aFloater

In this case i put whole of a floater into a txt filestream.

I hope i understood your question well, and am aware, that my method probably isn't the best way to go about it. it did work for me, though. But it does make your code les readable, which makes debugging a major PITA kind of a task.

hlapecjernej
06-25-2011, 03:47 AM
or as in your example:


/*
parameters SpcP rollout:SpaceRollout
(
SpcBlnd type:#float ui:MnSpc default:0
objs type:#maxobjecttab tabSizeVariable:true
)
*/
rollout SpaceRollout "SpaceSwitches" width:168 height:550
(
local objs = #()
Slider MnSpc "Free/Locked" type:#float range:[0,1,0]
pickbutton AdBtn "Add Object" width:140 height:35
subrollout SbRollout "SbSwitches" width:130 height:200


on AdBtn picked obj do
(
pkobj=nodeTransformMonitor node:obj forwardTransformChangeMsgs:false
append objs pkobj

(
txt = "rollout " + obj.name + " \"" + obj.name + "\" (\n"
txt += "slider " + obj.name + "_sld1 \"blend:\"\n"
txt += ")\n"
txt += "addSubRollout SpaceRollout.SbRollout " + obj.name + "\n"

execute txt
txt = undefined

/*
SpaceRollout.SbRollout.rol1.title = obj.name

rci = rolloutCreator obj.name obj.name
rci.begin()
rci.addControl #slider #sld1 "blend:"
rci.end()
addSubRollout SbRollout rci .def */
)
)
)


if z_floater != undefined then CloseRolloutFloater z_floater
z_floater = newRolloutFloater "trey" 200 525
addRollout SpaceRollout z_floater



i used it as a floater but it should make no difference.
If used in realworld app, there sould be done something, a test or what, about the new rollout's and slider's unique variable.name, to avoid a crash due to repeated varnames in case of selecting the same object.

CGTalk Moderation
06-25-2011, 03:47 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.