Notifications
Clear all

[Closed] How to "update" pos when selecting new object?

Need some help with my first Maxscript.
I’ve tried to make a numeric transform box that gets the default value from the selected objects position. That works for the first object selected but I need help “updating” the value if another object is selected. How is that done?

 try(destroydialog channelbox)catch() 
rollout channelbox "JS_ChannelBox"
(
spinner xSpin "Translate X" type:#float range:[-1e+008,1e+007,$.pos.x]
spinner ySpin "Translate Y" type:#float range:[-1e+008,1e+007,$.pos.y]
spinner zSpin "Translate Z" type:#float range:[-1e+008,1e+007,$.pos.z]
 
on xSpin changed newV do ($.pos = [xSpin.value, ySpin.value, zSpin.value])
on ySpin changed newV do ($.pos = [xSpin.value, ySpin.value, zSpin.value])
on zSpin changed newV do ($.pos = [xSpin.value, ySpin.value, zSpin.value])
 
)
createdialog channelbox width:192 height:318

1 Reply

You can use the callback mechanism of MAX to know when the selection changes. To do that, you have to register a callback function where you’ll handle the selection change code.

You can see an example of this in the MAXScript reference under the How To section:

How To … Develop a Selected Objects Inspector using ListView ActiveX Control – Part Two

Greets.