ScriptSpot

Forum topic · General Scripting

NodeEventCallback with array

By Aarc · 2018-09-28

Description

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

Comments (2)

Aarc · 2018-10-05

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 · 2018-10-03

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