MAXScript Language Reference > 3ds Max Objects > NURBS >

# Working with the NURBS Classes

Unlike other parts of MAXScript that let you script 3ds Max scene objects directly, the NURBS family of classes provides an indirect means of working with 3ds Max NURBS objects. They allow you to build an idealized structure representing 3ds Max NURBS objects and then use this structure to either create new or add to scene NURBS objects or to access certain parts of existing scene objects.

The structure is made up of instances of the MAXScript NURBS classes, listed in NURBS Classes. The main class for this is NURBSSet . It is the structure that corresponds to a scene NURBS object and contains a collection of NURBS items such as curves, surfaces, dependent surfaces, points, and so on, which are themselves instances of the other MAXScript NURBS classes. You construct a NURBSSet object describing a NURBS object and then have it be instantiated as a real scene object. Conversely, you can ask for a NURBSSet to be created that corresponds to a given scene NURBS object and use it to examine the component NURBS items and to modify certain properties directly on the scene object it describes.

Parameter Validity

The 3ds Max NURBS SDK methods and the corresponding MAXScript methods and properties perform very little parameter validation. As a result, passing invalid parameters to the functions or accessing invalid ranges will generate Assertion Failures easily. In most cases 3ds Max will not crash if Retry or Ignore is selected. An example of this is:

1. Create a CV surface and select it.

2. Enter in MAXScript:

    s = getnurbsset $ #relational
    obj = getobject s 1
    tess = getviewtess obj #displacement

This is invalid because the viewport does not support displacement approximation, only the production renderer does. Therefore, this will generate an Assertion Failure.

NURBSId's and Indexes

An important concept to understand when working with NURBSSets and the other NURBS classes, is the way you identify component items in the set. Before a NURBSet is instantiated as a scene NURBS object, the individual curves and points and surfaces are identified by an index number. As you append objects to the set they are assigned successive indexes, starting at 1. When you want to refer to a particular item, for example to specify the parent surfaces in a blend surface, you use this index. Once an object has been added to a NURBSSet, its index can determined through the .index property. This is a read-only property.

However, once a NURBSet is associated with a scene object, either by being instantiated or because it was directly created from an existing scene object, this index is no longer valid. Instead, a different number, called a NURBSId , is assigned to each item and you must use that Id when referring to items from then on. The NURBSId of any item in an instantiated NURBSSet can be obtained through the .NURBSId property on that object.

These identifiers, indexes or NURBSId's, are used in many places to specify the parent objects for other dependent objects. Often, these are specified using the .parent or .parentID properties on a dependent object. You must be sure to use the correct property depending on whether the containing NURBSSet has been associated with a scene object or not: .parent for non-associated NURBSSets, .parentID for associated NURBSSets. Remember that indexes used in .parent settings are 1-based.