GENERATE/PREV.gifGENERATE/NEXT.gif

Accessors

Accessors are constructs that let you access the components in compound values, such as arrays and 3D points. There are two kinds of accessors corresponding to the two kinds of compound values in MAXScript:

All MAX objects, such as boxes, spheres, bend modifiers, or bitmap textures, are treated as compound values in this sense, and all their parameters, such as height and angle, or map file name, are accessed as named components. In MAXScript, these named components are referred to as properties.

Accessors have one of two forms, an <array_index>:

<operand> [ <expr> ]      -- an indexed element

or a <property>:

<operand> . <name>      -- a named property

Examples:

maps[i]

selection[n + 1]

position.x

bend.angle

Because MAXScript is an origin 1 language, all sequencable collections in MAXScript start at index position 1. This is an important convention to remember when using the indexing operator.

The syntax definitions allow you to use any <operand> before the . or []. Because accessors are themselves operands, this definition is recursive, which means that you can string accessors together to query nested arrays or properties:

my_things[i][j]

my_objects[i].target.position.x

Accessors are evaluated left-to-right, so the first example evaluates the i’th element of my_things, which is presumably a nested array, before yielding the j'th element of that.

The second example retrieves an object from an array of my_objects, then its target, then the position of the target (a 3D point), and finally the x coordinate of that point.

Because an <operand> can also be a nested expression, you can compute the target object to be accessed, for example:

(pos * matrix1).x

(find_table "foo")[n - 2]

MAXScript values and objects with named properties are described in detail in the MAXScript Class Hierarchy topics.

See also:

Assignment to Accessors

Computed Property Access