startObjectCreation()

Topic: version 4 MAXScript Language Improvements/Language Improvements

The startObjectCreation() function has been enhanced.

startObjectCreation <maxobjclass> [returnNewNodes:<flag>] [newNodeCallback:<fn>]   

The values that can now be supplied to the optional 'returnNewNodes:' keyword argument are true, false (the default) or #first. If 'true' is supplied, all of the nodes created, up until the current create mode is exited, will be returned in an array. If #first is supplied, only the first node created is returned, immediately after it is created. The function doesn't wait for the create mode to be exited by the user.

The optional 'newNodeCallback:' keyword argument can supply a scripted function of one argument to the create mode that is started, such that the function will be called each time a node is created with the new node as its argument. This is similar to supplying pickObject() filter functions, although the return value of the newNodeCallback: function is ignored. Note that the callback function is invoked immediately upon new node creation, *before* any base object is installed in it, so *only* node-related properties can be accessed and changed during this callback.

Example:

fn setColor n = n.wireColor = red

startObjectCreation box newNodeCallback:setColor

would cause all new boxes created in the started create mode to have red wire color.

The 'returnNewNodes:' and 'newNodeCallback:' can both be supplied on the same call; the callback will be called on each node, and they will be returned in an array as the result of the startObjectCreation() function.

See also