MAXScript is an expression-based language. Every construct in the language is an expression and yields a result; this includes constructs that other languages consider statements. The simplified syntax of the language allows you to build very expressive code. Anywhere you can write an expression, you can write any construct in MAXScript.

A good example of this is the if construct. In statement-based languages, there is usually one syntax for if statements and another for conditional expressions. In MAXScript, a single syntax is used for both cases.

For example,

the following two lines of code are both valid, and their meaning should be obvious:

if a > b then print c else print d

x = if a > b then c else d

You can also write the following line, containing a nested if expression and a nested assignment, which itself is an expression:

x = if (if a > b then c else d) < e then f else (g = 23)

Another example is the block-expression, denoted . It contains a series of expressions enclosed in parentheses,

For example:


print a

print b

if a > b then print "the big a"


Each expression in the block is separated by a line break. You can also write several expressions on one line using a ";" (semicolon) to separate them:

(print a; print b; if a > b then print "the big a")

Block-expressions are themselves expressions. They evaluate their component expressions in sequence and yield as their value the value of the last expression in the block.

To create classic block-structured statements,

you might write:

if a > b then


print c

x = sqrt (c)




print d

x = sin (e)


or, use a nested block-expression to compute a comparison operand,

for example

if a > (y = sin b; sqrt(y * z)) then print c

At its simplest, a MAXScript program is made up of expressions. An is defined as any of the following:

This list of expressions constitute the main constructs in MAXScript.

See also

Simple Expressions

Context Expressions

Controlling Program Flow

Creating Functions

Structure Definition

Literal Constants

Variables - Assignment and Scope

3ds Max Commands

Scripted Utilities

Utility Clauses

Scripted Mouse Tools

Scripted Right-Click Menus

Scripted Plug-ins