Need a custom callback

Need a custom callback

Anonymous
Not applicable
579 Views
2 Replies
Message 1 of 3

Need a custom callback

Anonymous
Not applicable

Hello. I am trying to learn Maxscript. I wrote a script but i want to evaluate this script whenever i changed the position of my specific object in the scene.

I mean when i try to move a box object in the scene named as "Box001" for example i want max  to evaluate the script i wrote as i am dragging the mouse in viewport. I think that kind of function kan be achieved with callbacks but they are not detecting the object transform. Is there any way of doing that functionality? 

 

Thanks

0 Likes
580 Views
2 Replies
Replies (2)
Message 2 of 3

istan
Advisor
Advisor

a) if you changed the position from your script, why you don't evaluate there?

b) you could also think about using a position controller

c) you can use e.g. the redraw callback

0 Likes
Message 3 of 3

DDelapenaZ28WA
Explorer
Explorer

I think what you are looking for, is a change handler. Change handlers are usually executed by user events. Callbacks are typically initiated by other events within the scene. 

See Change Handlers and When Constructs

This example is from the docs above, at the bottom.. utilizing a transform change handler on the object box001. This executes when the users translates/rotates/scales the object.

 

b1 = box()
b2 = box()
b3 = box()
when transform $box001 changes do
$box002.pos = $box001.pos + delta
max select all
when names selection change obj do update_name_table obj
when #($box001, $box002, $box003) deleted obj do
(
messageBox "Warning!"
deleteItem obj_table (findItem obj_table obj)
)

hope this helps.

0 Likes