NodeEventCallback with array

Hello everybody.
Faced the problem of reading the properties of objects under given conditions.
The problem is this: when you select one object and when no objects are selected, everything works fine. When I try to select an array of objects
  there is trouble.
Can you tell me which way to think?
Thank you
The script itself:

rollout test "Test" width:162 height:300
(
	checkbox 'btn_Visibility' "Visibility" pos:[21,107] width:72 height:22 align:#left
 
)
 
fn CallbackProperties ev nodes =
		(
		 if $ == undefined do return false
 
            test.btn_Visibility.checked = ($.primaryVisibility == ON)
		)		
callbackItem = NodeEventCallback selectionChanged:CallbackProperties
 
createdialog Test
<code>

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Aarc's picture

Thanks for the answer. During

Thanks for the answer.
During that time, while waiting for the fasting post, I also found a possible solution to this problem.
Maybe someone will come in handy:

fn CallbackProperties ev nodes =
		(
			local CameraChecked = true;
			for i in selection do
			(
				if not i.primaryVisibility then 
				(
					CameraChecked = false;
					exit;
				)
 
callbackItem = NodeEventCallback selectionChanged:CallbackProperties renderPropertiesChanged: CallbackProperties
miauu's picture

.

Try this:

rollout test "Test" width:162 height:300
(
	checkbox 'btn_Visibility' "Visibility" pos:[21,107] width:72 height:22 align:#left
 
)
 
fn CallbackProperties ev nodes =
(
	if selection.count != 0 do
	(
		test.btn_Visibility.checked = ((selection as array)[1].primaryVisibility == ON)
	)
)		
callbackItem = NodeEventCallback selectionChanged:CallbackProperties
 
createdialog Test

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.