Controller Key Functions

addNewKey <controller> <time> [ #select ]

Adds a new key to the controller track at the time specified. The value for the new key is the interpolated controller value at the specified time. The new key is also selected if the #select optional argument is specified. The value for the new key is the interpolated controller value at that time. addNewKey() will not add a key if a key already exists at the specified time. The return value in this case is the key located at the specified time.

This function returns a MAXKey value representing the key so you can set its various properties. See Controller Key Functions for details.

deleteKeys <controller> [ #allKeys ] [ #selection ]

Deletes keys from the controller according to the optional symbolic argument supplied.

#allKeys (default): deletes all keys in the controller.

#selection: deletes the currently selected keys

deleteKey <controller> <index>

Deletes the indexed key. Key indexes are 1-based.

selectKeys <controller> [ <interval> | <time> ]

Selects the specified keys in the track view. If an interval is given, all the keys within the interval are selected. If a single time is given, the key at that time is selected. If no time or interval is given, select all keys.

deselectKeys <controller> [ <interval> | <time> ]

Deselects specified keys. Arguments are as described in selectKeys().

selectKey <controller> <index_integer>

Selects the indexed key. Key indexes are 1-based.

isKeySelected <controller> <index_integer>

Returns true if indexed key is selected, false otherwise. Key indexes are 1-based.

deselectKey <controller> <index_integer>

Deselects the indexed key. Key indexes are 1-based.

moveKeys <controller> <time> [ #selection ]

Moves the specified keys by the time given. If #selection is specified, move the current selection otherwise move all keys.

moveKey <controller> <index_integer> <time>

Move the indexed key by the specified time.

numKeys <controller>

Returns the number of keys in the controller. Returns -1 if you call it on a controller that does not support keyframing.

getKey <controller> <index_integer>

Returns the indexed key as a MAXKey instance. See Controller Key Functions for MAXKey class information.

getKeyTime <controller> <index_integer>

Returns the time of indexed key.

getKeyIndex <controller> <time>

Returns the index of the key at the specified time.

numSelKeys <controller>

Returns the number of keys currently selected in the track view.

sortKeys <controller>

Re-sorts keys according to their times. Some MAXKey operations can result in out of order keys and this function must be called to correctly order keys. See the Controller Keys and Key Properties topic for MAXKey properties information.

createLockKey <controller> <time> <rot_or_pos_integer>

This method is called to create a locking key at the specified time. This is a key that looks back to the previous key and creates a new key at the specified time which matches the previous key in value. It also adjusts the parameters for the key such that the value stays constant from the previous key to this key. For instance, for a TCB controller the continuity of the previous key and new key will set to 0. For a Bezier controller the out tangent type of the previous key is set to linear and the in tangent type of the new key is set to linear.

If the controller passed to this method is a transform level controller, <rot_or_pos_integer> specifies whether to create the key in the transform controller's position or rotation (or roll angle) sub-controller. If rot_or_pos_integer = 0, the key is created in the position controller. For all other values, the key is created in the rotation (or roll angle) controller.

If the controller passed to this method is not a transform level controller, the <rot_or_pos_integer> value is not used.

Returns true if the key creation was successful, false otherwise.

The following script shows example usages of some of the above methods.

Example:

-- controller test bed 2

b=box height:10

at time  5 animate on b.height=50

at time 10 animate on b.height=100

bhc=b.height.controller

bhk=bhc.keys

addnewkey bhc 7

addnewkey bhc 9

for k in bhk do format "%:%\n" k.time k.value

selectKeys bhc (interval 7 9)

deleteKeys bhc #selection

bhk

addnewkey bhc 7

addnewkey bhc 9

selectKeys bhc (interval 7 9)

deleteKeys bhc #selection #slide

bhk

addnewkey bhc 7

addnewkey bhc 9

selectKeys bhc (interval 7 9)

deleteKeys bhc #selection #slide #rightToLeft

bhk

addnewkey bhc 8

i=getKeyIndex bhc 8

selectKey bhc i

moveKey bhc i 10

bhk

getKeyTime bhc 4

b.width.controller=noise_float()

numkeys b.width.controller