Notifications
Clear all

[Closed] checkbutton initial state?

ehh, me again
while i cant figure out how to make the node thing work, let me ask another thing:
i have an attribute holder in a spline, with a checkbutton to hide/show another object , in this case box001. heres the script:



ca=CustAttributes.getDef $.modifiers[1].Controls
LM=$box001
attributes controls
redefine:ca
(
 rollout cbt "Check"
 (
  checkButton chbtHideMe "Hide Me"
 
  on chbtHideMe changed theState do
  (
   case TheState of
   (
	true:
	(
	 LM.isHidden = true
	)
	false:
	(
	 LM.isHidden = false
	)
   )
  )
 )
)

--custAttributes.add $.modifiers[1] ca

it works, but if i check the button, deselect the object, and select again, button will be unchecked. how to make an initial state for it? for (lame) example, “if box001 ishidden=true, button=checked”

thanks

4 Replies
 lo1

on cbt open do
(
chbtHideMe.checked = ($whatever.property == whatever)
)

alright, worked for that case, but how about lets say when i wired smooth iterations toa parameter “osmooth” and the checkbutton switches it between 0 and 1? for example:


on smoothB changed theState do
			(
				case TheState of
				(
					true:
					(
						osmooth = 0
					)
					false:
					(
						osmooth = 1
					)
				)
			)

how to do it in this case?

 lo1

on yourrollout open do
(
smoothB.checked = (if osmooth==0 then true else false)

)

same logic

p.s. this is the same as writing
(if osmooth==0 then smoothB.checked = true else smoothB.checked = false)

it’s just shorter

yeah, worked like a charm, thanks mate!