Phone: 905 409-1589
RSS LinkedIn Twitter Twitter

Name Independant Script Controllers:

This is no longer needed for Max 8 or higher.

Shows how to use CA defs to store reference nodes and access them with "this".

This was cut and paste from a reply that I posted on the Discreet Max web board at

Here is a quicky tutorial. Copy and paste the script below into a new script window in 3DS Max6 and higher and execute it.

This will create a sphere that when rotated on it's Z axis will change the value of the radius parameter. This is just an example of how to use a custom attribute definition to store a reference to a node or track on another object, or in this case itself.

Using the "this" construct will access the controller and then the CA def and track. Using "this" in conjunction with CA's will make the script controllers name independant and faster in big scenes.

Create a sphere and add a script controller to the radius track.
--Make Sphere and a script controller on the radius track of the sphere.
Create a custom attribute definition with a single parameter that can hold a float value. parameters can hold many types of objects and values and you can find a full listing in the Max help under scripted plugins.
--Create CA definition and assign it to the variable ca.
ca=attributes myAttrib
	parameters myParams
		myTrack type:#float
This will add the custom attribute parameters to the script controller. This can be seen in track view with the name myAttrib.
--Add the CA def to script controller

custAttributes.add con ca

Instance the controller from the Z rotation of the sphere to the CA parameter in the script controller. This could be done in track view or schematic as well.

Write the script and add it to the script controller.
The controller will update interactivley because of the reference to the controller.
"this" refers to the script controller itself. "this.myTrack" access the custom attribute track that holds the reference to the rotation controller.
"abs" makes the value in rotVal always positive so that if the sphere is rotated in a negitive value the radius goes up. An if statement could have been used here as well but this is far easier.
--Write the script and add it to the script controller.
str+="abs (rotVal+25)"