Sticky Attributes
Hi
I have scripted a camera rig interface using custom attributes. Now when I select a lens from a dropdown list it sets the focal length and disables some spinners. Howether when I deselect and then reselect the object the values have changed but the dropdown list reverts to position 1 and the spinners re-enable themselfs. How do I get them to remember there settings?
Thanks
My Code:-
rollout ro_lensControls "Lens Controls" width:162 height:77
(
label lab_fp "Focus:" pos:[20,8] width:99 height:16
spinner spn_dist "Dist:" pos:[35,31] width:99 height:16 range:[1,9999999,0]
label lab_lens "Lens Type:" pos:[20,54] width:99 height:16
dropdownlist ddl_lens items:#
(
"Free",
"14mm Prime f2.8",
"24mm Prime f1.4",
"35mm Prime f1.4",
"50mm Prime f1.2",
"85mm Prime f1.2",
"100mm Prime f2.8",
"200mm Prime f2.8",
"300mm Prime f2.8"
) pos:[20,70] width:120 height:16
on ddl_lens selected i do
(
if ddl_lens.selection == 1 then
(
$.modifiers[#Camera_Rig].ro_lensControls.spn_ffmm.enabled = true
)
if ddl_lens.selection == 2 then
(
ffmm = 14
ffnum = 2.8
$.modifiers[#Camera_Rig].ro_lensControls.spn_ffmm.enabled = false
)
if ddl_lens.selection == 3 then
(
ffmm = 24
ffnum = 1.4
$.modifiers[#Camera_Rig].ro_lensControls.spn_ffmm.enabled = false
)
if ddl_lens.selection == 4 then
(
ffmm = 35
ffnum = 1.4
$.modifiers[#Camera_Rig].ro_lensControls.spn_ffmm.enabled = false
)
if ddl_lens.selection == 5 then
(
ffmm = 50
ffnum = 1.2
$.modifiers[#Camera_Rig].ro_lensControls.spn_ffmm.enabled = false
)
if ddl_lens.selection == 6 then
(
ffmm = 85
ffnum = 1.2
$.modifiers[#Camera_Rig].ro_lensControls.spn_ffmm.enabled = false
)
if ddl_lens.selection == 7 then
(
ffmm = 100
ffnum = 2.8
$.modifiers[#Camera_Rig].ro_lensControls.spn_ffmm.enabled = false
)
if ddl_lens.selection == 8 then
(
ffmm = 200
ffnum = 2.8
$.modifiers[#Camera_Rig].ro_lensControls.spn_ffmm.enabled = false
)
if ddl_lens.selection == 9 then
(
ffmm = 300
ffnum = 2.8
$.modifiers[#Camera_Rig].ro_lensControls.spn_ffmm.enabled = false
)
)
label lab_foc "Focal Length:" pos:[20,100] width:99 height:16
spinner spn_ffmm "mm :" pos:[35,123] width:99 height:16 range:[1,999,0]
label lab_ap "Aperture:" pos:[20,146] width:99 height:16
spinner spn_fnum "F-stop" pos:[35,169] width:99 height:16 range:[0,999,0]
)
)
custAttributes.add $.modifiers[1] ca2
Comments
do you have the UI item
do you have the UI item linked to a var in the parameter block?
if so remove the link and set the var on ddl changed var
Raphael Steves
OOPS
setting the var on ddl changed var was working I had just declared it in the wrong part of the script outside the rollouts. I did'nt get any errors so I hadn't noticed.
g
Working now, Thanks
Got it working now :)
yeah something like ddlI
yeah something like ddlI where you save the index (not the name) of the selected item would do perfectly as the user might sometimes change the focus. when selecting a ddl item always do it by index never use the names
Raphael Steves
Hi, I am manually trying to
Hi, I am manually trying to change the selected item in the dropdownlist but with no luck. It always revert to positon 1.
on ro_lensControls open do
(
ddl_lens.selection = 4
)
Any ideas?
Thanks
Gram
set sel-prop in ddl definition
Dropdownlist selection property is 1 by default
but you can supply different value at runtime:
dropdownlist ddl_lens items:#( ... )
selection:4my recent MAXScripts RSS (archive here)
Thanks, I managed to fix it
Thanks, I managed to fix it by setting the selection with a variable at runtime. (as you have said, Ta!) And then setting the variable value on selection.
dropdownlist ddl_lens items:#( ... ) selection: ddlsel
g
thanks
Thanks, I will give it a try.
on ro_lensControls open do (
on ro_lensControls open do
(
--check the focal length and change UI config accordingly
)
Raphael Steves
Cheers
On another rollout I have checkboxes that enable sliders. I now check to see weather it is enbled on open and then re-set the sliders to there correct states. Thanks
On the dropdown list I don't know what the user has set it too. Should I store this seting in a variable that I can then call on open?
Thanks again for your help
Gram