Notifications
Clear all

[Closed] change handlers only work in x axis??

ok so i’ve just looked into using change handlers and when constructs for the purpose of moving a bunch of objects in relation to another. my first test was trying to make a teapot move to a point’s position when the point was moved. code is as follows:

when transform $Point01 changes id:#pntChange do
 (
 	$Teapot01.pos = $Point01.pos
 )

the problem is that the teapot does move to the point’s position when you first click the mouse on the move tool, BUT, whilst holding down the mouse, it will not stay aligned with it on any axis other than X.

this is not the desired effect and linking isnt an option unfortunatly. I am aiming for some kind of indirect link that updates in real time if that makes sense.

6 Replies

bump
and i would also be open to suggestions of any alternative methods

what exactly are you trying to achieve and why is linking not good enough?

mark

First of all,you should NOT use change handlers to do this, as the MAXScript Reference suggests. This was written back in 1997 by John Wainwright and still applies:

[left]Caution:
[/left]
[left]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, [size=3]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 [/size]handleAt: to delay the actual processing of the event handler script until a redrawViews or timeChange event occurs.
[/left]

As for your problem, there is a notification issue when using a Position_XYZ controller. (I would call it a bug as it walks and quacks like one). Somehow, only the first sub-controller (for the X axis) broadcasts notification, thus only the X axis appears to be updating when using the transform gizmo.

If you change the position controller of your objects to Bezier Position, it might work in your setup, but you should really consider using scripted controllers for this functionality.

Of course, your problem might be something else, but it really sounds like the Position_XYZ issue.

i would prefer using scripted controllers actually but i can’t seem to find any reference to accessing the interface options like creating variables and assigning them to a track etc. Perhaps i should have first asked if that was possible in mxs?
PS. i’m using max 8

1 Reply
(@bobo)
Joined: 11 months ago

Posts: 0

That was, to be honest, my fault.
It is possible to access them in Max 8, but I forgot to document the interface and added the description in Max 9. (The MAXScript Reference for 9 is freely available with the 30 days evaluation version, so you could download it).

Alternatively, just ask for the interfaces of a scripted controller:

showInterfaces (position_script())
  Interface: IScriptCtrl
   Properties:
	.ThrowOnError : bool : Read|Write
   Methods:
	<boolean>SetExpression <&TSTR>Expression
	   Expression is In parameter
	<TSTR by value>GetExpression()
	<TSTR by value>GetDescription()
	<boolean>SetDescription <&TSTR>Description
	   Description is In parameter
	<integer>NumVariables()
	<boolean>AddConstant <&TSTR>Name <&fpvalue>Constant
	   Name is In parameter
	   Constant is In parameter
	<boolean>AddTarget <&TSTR>Name Target Offset: Owner:
	   Name is In parameter
	   Offset default value: 0f
	   Owner default value: undefined
	<boolean>AddObject <&TSTR>Name Object
	   Name is In parameter
	<boolean>AddNode <&TSTR>Name Node
	   Name is In parameter
	<boolean>SetConstant Which <&fpvalue>Constant
	   Constant is In parameter
	<boolean>SetTarget Which Target Owner:
	   Owner default value: undefined
	<boolean>SetObject Which Object
	<boolean>SetNode Which Node
	<boolean>DeleteVariable Which
	<boolean>RenameVariable Which <&TSTR>Name
	   Name is In parameter
	<time>GetOffset Which
	<boolean>SetOffset Which Offset
	<boolean>VariableExists <&TSTR>Name
	   Name is In parameter
	<fpvalue by value>GetConstant Which
	<value>GetTarget Which asObject:
	   asObject default value: false
	<maxObject>GetObject Which
	<node>GetNode Which
	<value>GetValue Which asObject:
	   asObject default value: false
	<value>GetVarValue Which
	<enum>GetType Which
	   GetType enums: {#unknown|#target|#constant|#object|#node
	<TSTR by value>GetName Index
	<index>GetIndex <&TSTR>Name
	   Name is In parameter
	<void>Update()
	<TSTR by value>PrintDetails()
   Actions:
OK

The methods are very similar to the ones in the Expression controller which was documented in 8.

brilliant! thanks bobo. this should work nicely.