The syntax for general assignment, <assignment> , is:
where <destination> can be one of:
Each of these destination type is described below.
MAXScript provides a swap() method that takes two valid assignment destinations as arguments and swaps their values. Its syntax is:
A variable is identified with a MAXScript <var_name> , as described in Names. If <destination> is a var_name , it identifies the variable to be assigned a value, as shown in the following examples:
If <destination> is a <property> or an <array_index> , the assignment is to an accessor. Accessors are constructs used to 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:
The component values are arranged in an indexable sequence, as in arrays or strings.
The compound value contains a fixed set of named components, as with 3D points and time intervals.
All 3ds Max objects, such as boxes, spheres, bend modifiers, or bitmap textures are treated as compound values in this sense. 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. For more information, see Properties, Methods, Operators, and Literals.
Accessors have one of two forms, an <array_index> :
The syntax definitions allow you to use any <operand> before the . or [] . Because accessors are themselves operands, this definition is recursive, which means you can string accessors together to query nested arrays or properties:
Accessors are evaluated left-to-right. The first example evaluates the i’th element of my_things , which is presumably a nested array or an array of strings, before yielding the j'th element of that element.
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.
An <operand> can also be a block-expression, allowing you to compute the target object to be accessed.
The named properties defined for the MAXScript values and classes are documented with the value and class descriptions.
In an assignment, <expr> is evaluated before <destination>, as can be seen in the following example:
Assignment in MAXScript is itself an expression and yields the value just assigned. Therefore, you can use assignments inside other expressions or cascade assignments, as in: