Modifying Existing NURBS Objects

The classes can also be used to modify the properties of existing NURBS objects in the scene. To gain access to an internal 3ds Max NURBS object, you must have the data copied into a NURBSSet. This is done using the node method getNURBSSet() . You can then use the methods of the NURBSSet to access the objects.

For example, the following sample code attempts to grab the first NURBS sub-object from the first node in the current selection set. It then checks if it is a blend surface and if so, adjusts one of the tension parameters.

EXAMPLE

-- get the first node in selection
node = selection[1];
-- make sure creation has been completed on the node
stopCreating node
-- get the nurbs set for it
getSet = getNURBSSet node #relational
-- extract the first obj, check class & set tension
obj = getObject getSet 1
if classOf obj == NURBSBlendSurface then obj.tension1 = 2.0

The type of modifications that you can perform in this way are limited to changing those parameters and properties that do not alter the structure of the NURBS scene object. You can modify point and CV positions, CV weights, and dependent object parameters such as, offsets and extrude amounts. You cannot add or delete objects, change the number of CVs or knots or parent curves, and so on. To do this kind of structural modification, use the appendObject() , setObject() , and removeObject() functions defined in NURBSSet : Value and the addNURBSSet() , breakSurface() , and similar functions defined in NURBS Node Properties and Methods.

The stopCreating() method is used to ensure that the specified node is fully created. This method is primarily used to ensure that a NURBS scene object is fully created, which it will not be until the creation is stopped. The NURBSSet returned for a NURBS scene object will not be complete if the object is still in creation mode. This method will also deactivate any activated object create buttons in the Create panel.

There are other global functions that might be used to modify NURBS scene objects. These functions are documented in NURBS Node Properties and Methods. For instance, developers can use the function breakSurface() to take an existing NURBS surface and break it into two separate surfaces.

Non-relational NURBSSets

You can also use the getNURBSSet() function in a non-relational mode, but not supplying the #relational argument to retrieve a "flattened" version of the NURBSSet in which all dependent surfaces such as, blends, offsets, and lofts are represented as independent curves and surfaces, and there is no 'live' connection back to the scene object from which the NURBSSet was derived. You might use this to get a simplified version of the NURBS scene object for an export script. For example, if the destination system does not support relational objects. You can also use a non-relational NURBSSet derived in this way as the basis for creating other scene objects such as, modifying or adding to the set and then re-instantiating it with the NURBSNode() function.