[Closed] Tristate checkbox in a Custom attribute?
Hi,
Using Max 2016, I cant get checkboxes in a CA (custom attribute) which is applied to a scene object, to stay on tristate value 2 (greyed out with a tick).
After my code creates the CA and applies it to the object, it sets the CA parameters, at which point the greyed out checkboxes do show correctly in the UI.
However, if I deselect and reselect the object or just switch to the create tab and then back to the modifer tab, all these greyed out check boxes are set to off.
Test Code:
CA = attributes "CASettings"
(
parameters main rollout: params
(
ParamCheckBoxA type:#integer ui:CheckBoxA default:2
)
rollout params "checkboxes"
(
checkbox CheckBoxA "CheckBoxA"
)
)
--apply CA to test box
try delete new catch()
new = Box()
custAttributes.add new CA
max modify mode; select new
new.baseobject.CASettings.params.CheckBoxA.triState=2 --this works but is not sticky and returns to checkbox Off
(note: Ignore space before e in triState above as this is added by the forum code tag)
I also tried the following line to set the checkbox via the CA parameter but it just sets the checkbox to ON:
new.baseobject.ParamCheckBoxA = 2 --This simply checks ON the checkbox
Any assistance would be hugely appreciated!
Many thanks
ca = attributes ca
(
parameters params
(
tristate type:#integer animatable:off
/**** not really necessary*
on tristate get val do
(
this.params.updateTristate()
val
)
*/
on tristate set val do
(
this.params.updateTristate()
)
)
rollout params "TriState"
(
checkbox ui_tristate "TriState"
on ui_tristate changed state do undo "Set TriState" on tristate = if state then 1 else 0
on ui_tristate rightclick do undo "Set TriState" on tristate = 2
fn updateTristate =
(
if ui_tristate.tristate != tristate do ui_tristate.tristate = tristate
)
on params open do updateTristate()
)
)
delete objects
b = box isselected:on
custattributes.add b ca baseobject:on
b.ca.tristate = 2
here is the only way i see…
if anyone is interested i can explain why there is no way to wire a checkbox’s tristate directly
Thank you very much, Denis!
Yes, I am curious about why there is no way to wire directly.
Is it an issue with CA implementation of legacy boolean checkbox vs newer tristate operation?