Drawing a Box with MAXScript

In the previous lessons you have seen some of MAXScript’s useful capabilities; however, nothing that is visible in the interface. MAXScript is also useful for working with regular objects, such as boxes or cylinders. You can draw a box in MAXScript just by entering the box() command:

box()

This creates a box with the default parameters. It is generally better practice to assign an object to a variable, so you can later refer to it by name and manipulate it using that name:

mybox = box()

When you use MAXScript to create an object without specifying any parameters, it is important to use empty parentheses, "()". This tells MAXScript to use the default parameters for the object. If you want to specify any of the parameters during creation, such as the size or location of the object, you do not need parentheses.

FOR EXAMPLE:

mybox = box length:20 width:20 height:20

MAXScript returns the box object name and the position of the box:

 

This example creates a box, and supplies three parameters: the length, width, and height of the box. The parameter names are followed by a colon and then by the value for that parameter. You can enter all parameters, without any punctuation between them.

MAXScript returns the following statement:

$Box:Box001 @ [0.000000,0.000000,0.000000].

The values inside the brackets represent the x, y, and z coordinates of the center of the box.

MAXScript also draws the box in the viewports, as shown in this perspective viewport:

 

Notice that you can use Undo (as you can with most MAXScript creation and modification commands) to remove the box from the scene.

Next Topic

Modifying the Box