PDA

View Full Version : "When transform..." issues


Chinwagon
12-19-2006, 10:08 PM
Hey there,
I tried making and auto ik snap system as a checkbutton in a custom attribute. Basically I wrote a function that snaps the rotation of some objects to some others. The function works fine, but when I make it the function happen whenever a certain object is moved using the "when transform $blah changes do" command, it only half works.
As I first start to move the "blah" object the snap happens but I can only move that object on one axis. The "blah" object's position correctly updates only when I begin to move it again.
In the online help, this example is given:
when transform $box01 changes do
$box02.pos = $box01.pos + delta


but when I evaluate it, it doesn't recognise the "delta" variable and without it, it doesn't evaluate correctly (the $box02 position doesn't match $box01's).
Should I be defining a "delta" variable for it to work correctly? Is putting a "when transform" statement inside a custom attribute going to give me grief? What's the best way to do this?
:)

Bobo
12-19-2006, 10:33 PM
delta should be defined as a Point3 value you want to use as offset.

Then again, the MAXScript Reference says the following:

Caution:

The change handler system is based on 3ds Max's internal notification system which essentially drives all animation and interactivity within 3ds Max. There are cases when the core sends many, many signals for the same change, so setting up change handlers on many objects that do vast amounts of computing can significantly slow down the system. Strictly speaking, change handlers are supposed to be used to just set "dirty flags" in a lightweight, order-independent way, and then use Redraw Views or Time Change callbacks to actually cause the triggered processing. You should attempt to use change handlers judiciously,


and not, for example, as a simple way to get scripted controllers.


If you do find that a desired setup is being flooded with unnecessary signals, you should use the handleAt: to delay the actual processing of the event handler script until a redrawViews or timeChange event occurs.




This was written in R2 days, but is still valid today. If you want to update stuff interactively, use a real scripted controller to monitor node changes.

Chinwagon
12-20-2006, 10:06 PM
Thanks for the reply Bobo, but the objects that I want to snap to others I still want to be able to transform after the fact. If I use a script controller on the transforms, I won't be able to do that. Should I be using a script controller assigned to a CA controller to do the snapping instead of using the CA script itself?
Also, how can I turn off that specific change handler (if I end up using it) when it randomly generates an id after I enable it?

CGTalk Moderation
12-20-2006, 10:06 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.