PDA

View Full Version : Scripted Rollout GUI on CA-- Question on historical user interaction from timeSlider


Archangel35757
12-12-2010, 06:36 PM
Hello, I'm new to MAXscript and am currently creating a rigging GUI scripted rollout on a Custom Attribute (which has a button that launches the rollout GUI).

I'm in the process of creating event handlers now for the buttons, and I've run into a problem (sort of)...

I have two checkbuttons labeled "ON" and "OFF" and they are controlling the height of a cylinder from either 0 to full height (extending/retracting over a user spinner-specified number of frames). I have the "ON" / "OFF" checkbuttons setup up where they toggle each other's enabled state (so choosing "ON" forces user to choose "OFF" and vice versa-- and this is working like I want).

However, after placing some "ON"/"OFF" keys for the cylinder using the ON/OFF checkbuttons... I've noticed that when scrubbing the time slider the "ON" / "OFF" checkbuttons do not reflect their proper historical state-- but rather only shows the last keyframed state (whether that be "ON" or "OFF")-- have I explained this well enough?

My question is-- how do I get the "ON" / "OFF" check buttons to reflect their historical states for previously keyed frames when scrubbing the time slider (and not just the last ON/OFF keyframe state)???

Any assistance is greatly appreciated.

elT
12-12-2010, 06:54 PM
I'd suggest using multiple radio buttons instead.
from the help:

"A radiobuttons control is used to place a set of radio buttons on the rollout, only one of which can be checked at a time. The user can click different buttons in the set to change states."

Use two buttons labeled on and of and just case of switch to get what you need. Should be much easier to code and will probably work the way you want from the get go.

Hope it helps.

Cheers!

Archangel35757
12-12-2010, 07:08 PM
I'd suggest using multiple radio buttons instead.
from the help:

"A radiobuttons control is used to place a set of radio buttons on the rollout, only one of which can be checked at a time. The user can click different buttons in the set to change states."

Use two buttons labeled on and of and just case of switch to get what you need. Should be much easier to code and will probably work the way you want from the get go.

Hope it helps.

Cheers!

Thanks, but I wanted to use the on "rightclick" event handler available to checkbuttons to do something unique on frame 0. Do radiobuttons have a "rightclick" feature? The reference didn't say they did-- thus my choice of checkbuttons. Would radiobuttons reflect their clicked-history in the rollout when scrubbing the timeslider to look at previous frames/keys?

elT
12-12-2010, 07:11 PM
Or in case you don't need multiple buttons really, just an on off state, a single Check box will do. Depending on the new state of the checkbox you can change it's label to reflect the current state.

rollout newTest "NEW TEST"
(
checkbutton checkTest "on" checked:true
on checkTest changed theFlag do
(
print theFlag
if theFlag == false do
(
checkTest.text = "off"
print "IT's OFF"
)
if theFlag == true do
(
checkTest.text = "on"
print "IT IS ON!"
)

)


)

createdialog newTest

Archangel35757
12-12-2010, 07:15 PM
Thanks, I do see that I could've done it with one checkbutton (and managing its state) as you've demonstrated... however, what I'm keen to learn is how do you make a checkbutton reflect it's past ON/OFF state when scrubbing the timeslider? In my rollout, the checkbuttons do not reflect past ON/OFF states when scrubbing the timeslider-- only the last state is maintained when scrubbing the timeslider. Does that make sense?

elT
12-12-2010, 07:17 PM
Thanks, but I wanted to use the on "rightclick" event handler available to checkbuttons to do something unique on frame 0. Do radiobuttons have a "rightclick" feature? The reference didn't say they did-- thus my choice of checkbuttons. Would radiobuttons reflect their clicked-history in the rollout when scrubbing the timeslider to look at previous frames/keys?

the Example of the check button, updated (added a parameter), when animated the state of the button does update but the text of the button doesnt, meaning, it's last state is there. which is only natural IMO.


test_checkAttribute = attributes checkTesting
(
parameters testinParameters rollout:newTest
(
testParam type:#boolean ui: checkTest animatable: true
)
rollout newTest "NEW TEST"
(
checkbutton checkTest "on" checked:true animatable:true
on checkTest changed theFlag do
(
print theFlag
if theFlag == false do
(
checkTest.text = "off"
print "IT's OFF"
)
if theFlag == true do
(
checkTest.text = "on"
print "IT IS ON!"
)

)


)

)
custAttributes.add $.modifiers[1] test_checkAttribute


In max 2010, radiobuttons have right click event.

Cheers!

elT
12-12-2010, 07:20 PM
Thanks, I do see that I could've done it with one checkbutton (and managing its state) as you've demonstrated... however, what I'm keen to learn is how do you make a checkbutton reflect it's past ON/OFF state when scrubbing the timeslider? In my rollout, the checkbuttons do not reflect past ON/OFF states when scrubbing the timeslider-- only the last state is maintained when scrubbing the timeslider. Does that make sense?

You just add a parameter, a boolean paramter in the paramteres block like in the example above.

Then, when animated, the state of the button does change on it's keyframes. However, their text does not. You could try adding a new string parameter and pipe it in the label but I'm not sure it would work or if it would crash max.

Archangel35757
12-12-2010, 07:23 PM
I'm using 3dsMax 8, so I'll check and see if the rightclick event handler works for radiobuttons. Hmm, as you pointed out, maybe it's because I don't have the AutoKey button activated and/or I'm missing the animatable boolean feature for the checkbutton...

I'll make the boolean modifications to make them animatable and that should fix it. Thanks for your help-- it's greatly appreciated.

elT
12-12-2010, 07:25 PM
You just add a parameter, a boolean paramter in the paramteres block like in the example above.

Then, when animated, the state of the button does change on it's keyframes. However, their text does not. You could try adding a new string parameter and pipe it in the label but I'm not sure it would work or if it would crash max.

It seems I can't manage to get the label switching, but I'd guess it isn't that important.

elT
12-12-2010, 07:28 PM
I'm using 3dsMax 8, so I'll check and see if the rightclick event handler works for radiobuttons. Hmm, as you pointed out, maybe it's because I don't have the AutoKey button activated and I'm just using the "with animate on" in the event handlers to set keys for the ON/OFF checkbuttons... I'll play with that and see.

Thanks for your help-- it's greatly appreciated.

The whole thing is in custom attributes, right?

IMO, it's best to use the parameters block to define parameters to be used by the rollout. Right there you can set them to animatable:true and not worry about the rest. Your buttons will reflect their keys.

BTW, i've used checkbutton in my examples but it's virtually identical to checkbox. Just a FYI.

And you're welcome, it's great to be able to help and spread the love. :)

Cheers!

Archangel35757
12-12-2010, 07:30 PM
Ok... I'm not able to get your suggestions working because MAXscript is giving me errors for trying to put in a parameter block that attempts to point to the "floating rollout" defined within the custom attribute's rollout.


I have attached an example scene and script... so that someone knowledgable can help me achieve what I'm wanting to do-- which is have the ON and OFF buttons (and other future buttons...) reflect their previous states by making them animatable; also for future UI sliders, etc. define parameters for wiring them to the Max standard interface controls for bi-directionality (e.g., if the user changes a constraint weighting in the standard Max interface, I want that to update my slider in the floating rollout and vice-versa).

Any help is greatly appreciated.

elT
12-13-2010, 03:32 PM
I can't seem to make it work, this what you want, so I really have no answer.

I do have a question though, do you really have to have this in a separate floating dialog? Because if you don't, you can have this working easily directly in modify panel.

Otherwise, the problem seems to be in defining parameters for a rollout that isn't there as far as maxscript is concerned. The way you defined it is a rollout within a rollout.

The other problem is, if you define separate parameters for the new dialog those might be destroyed and initialized every time the dialog is closed/open.

The workaround might be in this:

define the parameters you need in parameters block.
define two rollouts.
tie the parametes to the first rollout.
Find a way to instance the parameters from the first rollout to the second when creating the dialog.


But it seems to me it's way more complicated then it needs to be. I don't know what the end usage of your script should be but unless you really really really have to have it in a separate dialog, do it directly in the attribute holder, it will be much easier to write and is guaranteed to work.

Archangel35757
12-13-2010, 03:49 PM
...But it seems to me it's way more complicated then it needs to be. I don't know what the end usage of your script should be but unless you really really really have to have it in a separate dialog, do it directly in the attribute holder, it will be much easier to write and is guaranteed to work.

Well, I just wanted the "animation user interface" to be in a floating dialog rollout so that I don't have to have the modify panel opened up on the helper object that actually contains the custom attribute holder.

I did find a solution... and it seems like it will work-- I haven't gotten too far into it. It seems to follow the outline of your suggestion. Here is the link to the forum post on ScriptSpot where someone wanted to do the same thing, and it looks like user MarTroYx (Martin) came up with a working solution:

http://www.scriptspot.com/forums/3ds-max/general-scripting/rig-gui-question (http://www.scriptspot.com/forums/3ds-max/general-scripting/rig-gui-question)

I'll delve more into Martin's solution this evening when I'm home from work. Thanks for your help.

elT
12-13-2010, 06:43 PM
Seems quite cool. Best of luck!

However, I'd like to point out two things regarding having the gui always available from the modify panel without the floater:

You can pin the stack, having the modifier panel showing always the attributes on the helper

or

You can copy / paste instance the attribute holder on the control nodes you have, that way, you can have the GUI accessible on all the control nodes. (this one works for me all the time) as in: FK/IK switching/blending on spine/arms/legs.


That's just in case you run in to problems with implementing the floater.

Cheers!

CGTalk Moderation
12-13-2010, 06:43 PM
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.