Notifications
Clear all

[Closed] SelectionSetsChanged Callback & Select Command


-- create a sphere for demonstration purposes
sphere name:"mySphere"

callbacks.addScript #selectionSetChanged "
	if ($mySphere.isSelected) then ( print \"mySphere is selected\" )
	else ( print \"mySphere is NOT selected\" )
" id:#test 

The above code was taken from one of the previous thread from Zeboxx.

I realize the callback is called once correctly, if you were to use a mouse click on the sphere.

but when you type “select $mySphere”, you will be getting double called.
It seems like select command actually issue 2 times on selectionSetschanged (deselect current then select the sphere)

However it doesn’t happen twice with mouse event when it trigger selectionSetsChanged.

Is there anyway I can correct it as I wouldn’t want it to get called twice when i do a select command inside a script?

Thanks.

4 Replies

if you’re using 3ds Max 2009, you could use the second method ( nodeEventCallback ):
http://forums.cgsociety.org/showpost.php?p=5414055&postcount=2

That does seem to ignore the deselection event from select()

alternatives include performing the action time-delayed – but that’s pretty nasty

Hi thanks ZeBoxx2.

Too bad, I’m stucked with 3ds max 2008 >.<

Well now I just had to insert that xxnode.isSelected as a condition check for callback to prevent double call.:hmm:

yeah, can’t do much about the double callback – if all you’re interested in is whether an object gets selected, then checking whether .isSelected is true will do just fine.

If you’re doing this for a specific object or set of objects, there is one other option in changeHandlers – but it looks like it will do a double event as well if the sphere is already selected and you call ‘select $mySphere’ (first deselecting, then selecting again).

blame ‘select <node>’

just to follow up on select(); if it’s only your own script doing selecting/deselecting you’re worried about, you could work with deselect() and selectMore() instead; selectMore() won’t deselect / re-select a node if it’s already selected, and won’t cause two events that way.