|
|
|
Tell us what you think of the site.
|
Autodesk Media & Entertainment User Community
|
Autodesk® 3ds Max®
|
|
Autodesk® Maya®
|
|
Autodesk® Softimage®
|
|
Autodesk® MotionBuilder®
|
|
Autodesk® Mudbox™
|
|
Autodesk® ImageModeler™
|
|
Autodesk® Sketchbook® Pro
|
|
Autodesk® Smoke on Mac®
|
| Add different preset values to spinners when clicking a button...?
|
|
|
Hi All
i’m trying to have a set of spinners which i can update with preset values by clicking different buttons.....
ie. click button1 to update spinnerA with 1.0 spinnerB with 0.5 etc.
click button2 to update spinnerA with 0.5 spinnerB with 1.2 etc.
do you know if this is possible? cannot seem to find any way to do it....
thanks in advance :)
Neil
|
|
|
|
utility test "Test" (
fn preset1 val1 val2 = (val1 = 1.0 ; val2 = 0.5)
fn preset2 val1 val2 = (val1 = 0.5 ; val2 = 1.2)
spinner spnA "A:" range:[0,100,0]
spinner spnB "B:" range:[0,100,0]
button btnP1 "Preset 1"
button btnP2 "Preset 1"
on btnP1 pressed do ( preset1 spnA.value spnB.value )
on btnP2 pressed do ( preset2 spnA.value spnB.value )
)
Max 9 through 2009, XP-Pro x64 SP2
ASUS EAH3450 Series (Driver 8.470).
Core 2 Duo E8400 3GHz, 4Gb Ram, DX9.0c.
|
|
|
|
|
Would those function params not have to be “in” (or “out") values - passed by reference not by value? Not sure if you can pass object properties as references though - would have to test that.
Author: Steve_Curley
|
| Replied: 27 August 2010 01:14 AM
|
|
|
|
|
|
Ok, it does work, if the params are by reference.
utility test "Test" (
fn preset1 &val1 &val2 = (val1 = 1.0 ; val2 = 0.5)
fn preset2 &val1 &val2 = (val1 = 0.5 ; val2 = 1.2)
spinner spnA "A:" range:[0,100,0]
spinner spnB "B:" range:[0,100,0]
button btnP1 "Preset 1"
button btnP2 "Preset 1"
on btnP1 pressed do ( preset1 &spnA.value &spnB.value )
on btnP2 pressed do ( preset2 &spnA.value &spnB.value )
)
Author: Steve_Curley
|
| Replied: 27 August 2010 01:39 AM
|
|
|
|
|
|
Thanks for the reference variables correction Steve. I forgot to test my example ;)
Author: Anubis
|
| Replied: 27 August 2010 09:02 AM
|
|
|
|
|
thanks for the response, however i cannot seem to get this to work.....
i just added the code to dispaly the dialog.... but the buttons do not respond, do you have any idea why?
thanks again :) Neil
utility test "Test" (
fn preset1 val1 val2 = (val1 = 1.0 ; val2 = 0.5)
fn preset2 val1 val2 = (val1 = 0.5 ; val2 = 1.2)
spinner spnA "A:" range:[0,100,0]
spinner spnB "B:" range:[0,100,0]
button btnP1 "Preset 1"
button btnP2 "Preset 2"
on btnP1 pressed do ( preset1 spnA.value spnB.value )
on btnP2 pressed do ( preset2 spnA.value spnB.value )
) createDialog test 180 450 1350 100
|
|
|
|
( rollout Test "Button Test" width:208 height:108
(
spinner spn1 "" pos:[25,23] width:61 height:16
spinner spn2 "" pos:[122,24] width:61 height:16
button btn1 "1.0/0.5" pos:[26,67] width:53 height:22
button btn2 "0.5/1.2" pos:[122,63] width:56 height:30
on btn1 pressed do
(
spn1.value = 1.0
spn2.value = 0.5
)
on btn2 pressed do
(
spn1.value = 0.5
spn2.value = 1.2
)
)
try destroyDialog Test catch() createDialog Test )
[edit]:oops: - just saw Anubis’s reply [/edit]
Max 4.2 through 2013.
XP-64 (SP2)
NVidia 9800GTX-512 (Driver 266.58).
Core 2 Quad Q6600 2.4GHz, 8Gb Ram, DX9.0c.
|
|
|
|
Excuse my stupid mistake above, it come from my working style :)
i.e. my coding declaration goes…
1. Local variables
2. Main Functions
3. UI controllers
-----------------------
4. UI Functions
Usually all functions (in UI’s) are declared before the rollout controllers (alias good practice), but I found as useful to add the functions that control the UI after that with “hard-coding” path to the controllers. This benefit me with more simplified usage of the function inside the code. So, if you find this style useful, here is an example:
if classOf Test == RolloutClass do destroyDialog Test
rollout Test "Button Test" (
spinner spnA "A:" range:[0,100,0] across:2
spinner spnB "B:" range:[0,100,0]
button btnP1 "Preset 1" across:2
button btnP2 "Preset 2"
fn presets id = (
case id of (
1: (spnA.value = 1.0 ; spnB.value = 0.5)
2: (spnA.value = 0.5 ; spnB.value = 1.2)
)
)
on btnP1 pressed do ( presets 1 )
on btnP2 pressed do ( presets 2 )
) createDialog Test
Max 9 through 2009, XP-Pro x64 SP2
ASUS EAH3450 Series (Driver 8.470).
Core 2 Duo E8400 3GHz, 4Gb Ram, DX9.0c.
|
|
|
|
|
|