Objects and Classes in Object-Oriented Programming

To understand the terminology associated with MAXScript, a basic understanding of object-oriented programming is required.

All of the values you work with in MAXScript have a well-defined type, such as integer, matrix3, ortwist. The type of a value is also known as its class, following the convention of modern object-oriented languages. We've been using a somewhat neutral convention so far of calling the things you compute with values. The term for these things in object-oriented languages is, not surprisingly, object. The terms object and value are synonymous in this document. An object is a particular instance of a class.

For example, in MAXScript Box is a class. It is not a box as shown in 3ds Max, but rather defines the characteristics such a box has. These characteristics include the ways to create an instance of the Box class (a box object); the properties of a box object (such as Height, Width, and Length); and operations you can perform on a box object (such as move, copy, and delete).

To create a box object, you would say:

b=box()

In this line box() is a constructor - it causes a box object to be created, and returns a reference to the box object. This reference is then stored in variable b . No parameters (such as Height, Width, and Length) were supplied for the constructor, so the default values specified by the Box class are used. In the 3ds Max viewports, the box object is displayed, and can be manipulated like any other object you create in 3ds Max.

If parameters are supplied for the constructor, these parameters replace the " () ".

FOR EXAMPLE

b=box width:10 length:100

creates a box object with the supplied parameters. All unsupplied parameters will use their default values.

MAXScript is internally object-oriented. All the built-in classes are arranged in an inheritance hierarchy and most of the built-in functions are polymorphic, terms we'll explore below. You cannot, however, create new classes in MAXScript and the functions you can script are not polymorphic. This may change in later versions of MAXScript, but it is an advanced refinement that is not really necessary in an application scripting language, where the most important abstractions are the features of the host application and are already built-in.

See Also