when select [array] changes do?

when select [array] changes do?

gibzie90
Participant Participant
1,278 Views
4 Replies
Message 1 of 5

when select [array] changes do?

gibzie90
Participant
Participant

i'm looking for a way to run a command when an object from my array is selected but not sure how?

 

This is how i thought it would be written but it doesn't work, Max gives me this error:

Runtime error: Change handler setup requires a MAX object or MAX object collection, got: undefined

global cc_B = #($a_obj, $b_obj, $c_obj)

when select #cc_B changes do
(
    if #cc_B.isSelected then
    (
        print "cc_B selected"
        if IgnoreArm == true then
        (
            print "ignoring arm"
        )
    )
)

 

0 Likes
Accepted solutions (1)
1,279 Views
4 Replies
Replies (4)
Message 2 of 5

FranciscoHermida
Explorer
Explorer

Probably something you can do with callbacks.addScript #selectionSetChanged 
then checking if the current selection is in your array

www.boxofapps.com
0 Likes
Message 3 of 5

gibzie90
Participant
Participant
Accepted solution

Seems like i stumbled on to the answer...

 

when select cc_B changes do
( 
  for i in cc_B do
  (
    if i.isSelected then
    (
      print "test"
    )
  )
)
Message 4 of 5

FranciscoHermida
Explorer
Explorer

Thanks for sharing, didn't know this "when ... do" construct existed!

www.boxofapps.com
Message 5 of 5

gibzie90
Participant
Participant

No problem, I didn't know it existed until about a week ago either

0 Likes