Positional and Keyword Arguments

A function can take two kinds of arguments:

Optional keyword arguments are useful in command languages where commands can have many options. They are particularly useful within 3ds max where most functions have numerous optional keyword arguments. For example, all scene object creation functions take optional keyword arguments for their creation parameters. As there are sometimes more than 100 arguments to these functions, using positional arguments would simply be unworkable.

As an example of positional arguments, the syntax for the print function is:

print <value> [ to: <file> ]

<value> is a positional argument, and is required. to: <file> is an optional keyword argument, where to is the argument keyword and <file> is the argument value. If the to argument value is unsupplied, MAXScript outputs <value> to Listener. Otherwise, MAXScript outputs <value> to the file specified by <file>.

As another example, you can create a sphere object in the 3ds max scene with no arguments:

sphere()

Or, you could specify just one argument:

sphere radius:23

Or, you can specify more optional arguments:

sphere segs:20 smooth:on radius:15 hemisphere:0.5 mapcoords:on

For those keyword arguments not specified when creating 3ds max objects, default values are used. The default value used for each keyword argument is shown in the descriptions of the object classes.