GENERATE/PREV.gifGENERATE/NEXT.gif

Accessing Controller Keys and Key Properties

The keys and their properties on certain common kinds of controllers can be accessed in MAXScript. The supported controllers, which are the core keyframed controllers in MAX, are:

linear_float

linear_position

linear_rotation

linear_scale

bezier_float

bezier_position

bezier_point3

bezier_rotation

bezier_scale

bezier_color

tcb_float

tcb_position

tcb_point3

tcb_rotation

tcb_scale

For all key types, the following properties are accessible:

<key>.time      : time value or number (interpreted as frames)

<key>.value      : class determined by its containing controller

<key>.selected      : true or false

Changing the .time property of a key may cause it to go out of time order relative to the other keys in the controller. You must call the sortKeys() function on the controller or associated MAXKeyArray once all key time manipulations of this kind is complete so that animation will perform correctly.

The class of a key's value property is determined by the controller it is in, for example, a linear_float key has a float .value, a tcb_rotation key has a quaternion .value, etc. The properties are all settable and support the math-assignment operators and nested-property access. Here are some examples:

$foo.pos.keys[2].time += 20f

$box1.uvw_map.center.keys[2].value.x += 20

for k in $baz.bend.angle.keys do k.value *= 1.1

The units and scaling on a key's value property are as you would see in the MAX track view. For example, percentages are normally 1-100, angles are in degrees, colors are 0-255,0-255,0-255. This scaling is an attribute of the animatable property, not the controller, so in (the admittedly rare) situations in which a controller is shared by several animatables that have different scaling, you should take care to access the .value property through the correct animatable - this provides a scaling context for the access operation. For example,

c = bezier_float ()

$foo.bend.angle.controller = c      -- assign to bend angle

$baz.pos.controller.percent = c      -- and to path percent

shares the same controller between two differently scaled properties. You should access keys carefully in this case:

$foo.bend.angle.keys[1] = 45      -- degrees

$baz.pos.controller.percent.keys[2] = 100      -- percent