Node Common Methods

The following methods are applicable to any value that is derived from a Node.

Topics Navigation:
General Node Methods

Miscellaneous Node Methods

Node Render-Related Methods

Node Group-Related Methods

Node Viewport State Methods

Node Selection Methods

Node Modifier Stack Related Methods

Node Modifier Transform Context Methods
Node Deformable Methods

Node Bounding Box Methods

Node Conversion Methods

Node Utility Methods

Node User Properties Methods

Node Inverse Kinematics Methods

General Node Methods

Most node methods are automatically mapped over node collections.

IsValidNode <var> 

Returns true if <var> is a node value, and the node has not been deleted. Otherwise, it returns false .

move <node> <point3> -- mapped 
scale <node> <point3> -- mapped 
rotate <node> <angle> <axis_point3> -- mapped -- angle in degrees 
rotate <node> <quat> -- mapped 
rotate <node> <eulerangles> -- mapped 

All the transform operations operate in the current working coordinate system. See Context Expressions.

copy <node> -- mapped 
reference <node> -- mapped 
instance <node> -- mapped 

All the clone operations can take any of the standard node creation optional keyword arguments that are applied after the node has been copied.

These functions clone all the original node's transform controllers and keys, and the visibility controller and its keys if a visibility track has been assigned.

Note: maxOps.cloneNodes is the preferred way to copy, instance, or reference nodes. Node interdependencies are retained, and more of the node properties are copied across.
snapshot <node> -- mapped 

This function provides functionality that is similar to the SnapShot tool in 3ds Max. It generates a new node that contains a copy of the world-state mesh of the source <node> at the time that the snapshot is made. Any existing modifiers are collapsed out of the new node and the mesh snapshot accounts for any space warps that are currently applied. As with the clone methods (copy, reference, and instance,) you can add any of the standard node creation keyword arguments such as, pos: , name: , and others.

The following example achieves an animation-based snapshot similar to the SnapShot tool in 3ds Max:

FOR EXAMPLE:

   for t in 0 to 100 do at time t snapshot $foo
delete <node> -- mapped 

Deletes the specified node(s).

instanceReplace <dest_node> <src_node> -- mapped 
referenceReplace <dest_node> <src_node> -- mapped 

Lets you turn existing nodes into instances and references to other nodes. You can use these, for example, to replace the geometry of one node with another, perhaps for implementing custom level-of-detail tools.

The <dest_node> is turned into an instance or reference to the <src_node> . As a new instance, existing geometry and modifiers are removed and replaced by the <src_node> 's, but all the node-related properties are kept such as, material, transform, visibility, name, and so on. As a new reference, the base object for the <dest_node> becomes the world-state of the <src_node> such that any changes to the src_node will affect the <dest_node> , but changes to the <dest_node> are local to it.

It is possible to develop a custom scripted version of the File/Replace function with these functions and the mergeMAXFile() function by temporarily changing the name of a node in the current scene, merging in that named node from another, making the first node an instance of the newly merged node with instanceReplace() , deleting the newly merged node, and renaming the old node back again.

Both these functions are collection mapped, so you can make a selection of objects (all instance) or reference the same object.

FOR EXAMPLE:

   instanceReplace $foo* $baz
   --makes all the foo* objects be instances of baz's geometry
   --and modifier stack.
areNodesInstances <node> <node> 

Returns true if the two nodes are instances.

Available in 3ds Max 2008 and higher. Previously, available in the Avguard Extensions.

FOR EXAMPLE:

   InstanceMgr.GetInstances $ &rptInstances
   trueInstances = for n in rptInstances where\
   (areNodesInstances $ n) collect n
attachObjects <node1> <node2> [move:<boolean> ] 

Makes <node2> a child of <node1> . Resets the current location of <node2> to the location of <node1> unless move:false is specified.

getTMController <node> 

Returns the transform controller for the node.

bindSpaceWarp <node> <spacewarp_node> 

Binds the scene node to the space warp object scene node. Space warp bindings show up in the modifier stack and can be accessed like any other modifier. Use the deleteModifier() function to unbind objects from space warps. See Modifier and SpacewarpModifier for more information about working with the modifier stack.

getPolygonCount <node> 

Returns a two element array containing the current number of faces for the node in the first element, and the current number of vertices for the node in the second element. The number of faces and vertices returned are the number that is present if the node was converted to a mesh object.

isShapeObject <node> 

Returns true if the node is a shape object, false otherwise.

numSurfaces <node> 

Returns the number of parametric surfaces in the object. At the current time, Loft objects are the only objects where more than one surface is present (loft of a donut).

isSurfaceUVClosed <node> <surface_index_integer> 

Returns a two element array indicating if the parametric surface is closed in the U and V dimensions (a torus is closed in both U and V). Note that not all objects have this method implemented, and will return a default value of #(true, true) .

getTransformAxis (<node>|undefined) <index> 

Returns the transform axis of the indexed axis system of the node as a <matrix3> value. Normally, a node just has one transform axis. In some cases (like being in the Local Reference Coordinate System, in object SO mode, and having multiple SO selected), multiple transform axes exist. If index > the number of transform axis, the transform for the first transform axis is returned.

If the first argument is the value 'undefined' (instead of a node), the viewport common axis is returned. If the Coordinate System Center (getCoordCenter()) is #local or the Reference Coordinate System (getRefCoordSys()) is #local, #parent, or #gimbal, the last calculated common axis is returned.

The transform returned by this method can be used in an "in coordsys" context and an "about" context to move, rotate, or scale an object about the current 3ds Max UI Reference Coordinate System and Center.

FOR EXAMPLE:

   fn axisRotate obj rotation =
   ( 
   local axis
   local objA =if classof obj == objectSet or classof obj == array then obj else #(obj)
   if getCoordCenter() != #local then
   ( 
   axis = getTransformAxis objA[1] 0
   for obj1 in objA do in coordsys axis about axis rotate obj1 rotation
   )
   else
   ( 
   for obj1 in objA do
   ( 
   axis = getTransformAxis obj1 0
   in coordsys axis about axis rotate obj1 rotation
   )
   )
   )
invalidateTM <node> -- mapped 

Invalidates the node's transformation matrix cache.

invalidateTreeTM <node> -- mapped 

Invalidates the node's transformation matrix cache and notifies the node's subtree that the transformation matrix has changed.

The following MAXScript function can be used to force an update of an object whose transform is partially controlled by a scripted controller such as, a script controller on the position track:

FOR EXAMPLE:

   mapped fn TMInvalidate obj =
    ( at time(currenttime-1) obj.transform
    nodeInvalRect obj
    invalidateTreeTM obj
    redrawViews()
    )
getNodeTM {<node> | <rootnode>} 

Returns the transformation matrix of the given node or root node as a Matrix3value. The root node might be the root node of an XRef Scene object. Available in 3ds Max 2008 and higher. Previously, available in the Avguard Extensions.

invalidateWS <node> -- mapped 

Invalidates the node's world space cache.

getNodeByName <string> exact:<boolean> ignoreCase:<boolean> all:<boolean> 

Returns the first node with the specified name. If exact is false (default), the normal MAXScript node name comparisons are performed.

ignoreCase specifies whether the comparisons must be case sensitive or not. When set to true, non-case-sensitive comparison is performed.

If all is true, an array of nodes with the specified name is returned.

Default is exact:false ignoreCase:true all:false .

Note: When Fast Node Name Lookup is checked on the MAXScript tab of the 3ds Max Preferences dialog, case sensitive comparisons are done first, case insensitive comparisons (if enabled) are done second, and then inexact matching (if enabled). If Fast Node Name Lookup is off, the first node found that matches the conditions is returned. So, if you have two nodes called "AA" and "aa", and you use: getnodebyname "AA", if Fast Node Name Lookup is on you will always get node AA back. If Fast Node Name Lookup is off, you can get either node back because both nodes match the conditions.

EXAMPLE:

   --If you have a scene with 3 nodes: "AA", "aa", and "B B":

   $AA
   $Box:AA @ [...]
   $aa
   $Teapot:aa @ [...]
   $bb
   Sphere:B B @ [...]

   getnodebyname "AA" exact:true
   $Box:AA @ [...]
   getnodebyname "AA" exact:false
   $Box:AA @ [...]
   getnodebyname "AA" ignoreCase:true
   $Box:AA @ [...]
   getnodebyname "AA" ignoreCase:false
   $Box:AA @ [...]

   getnodebyname "Aa" exact:true
   $Box:AA @ [...]
   getnodebyname "Aa" exact:false
   $Box:AA @ [...]
   getnodebyname "Aa" ignoreCase:true
   $Box:AA @ [...]
   getnodebyname "Aa" ignoreCase:false
   undefined

   getnodebyname "aa" exact:true
   $Teapot:aa @ [...]
   getnodebyname "aa" exact:false
   $Teapot:aa @ [...]

   getnodebyname "B B" exact:true
   $Sphere:B B @ [...]
   getnodebyname "B_B" exact:true
   undefined
   getnodebyname "BB" exact:true
   undefined
   getnodebyname "B_B" exact:false
   $Sphere:B B @ [...]
   getnodebyname "BB" exact:false
   $Sphere:B B @ [...]

   getnodebyname "AA" all:true
   #($Teapot:aa @ [...], $Box:AA @ [...])

snapshotAsMesh <node> 

Returns world state of node as a <mesh> value.

getInheritanceFlags <node> 
setInheritanceFlags <node> (#all|#none| <bitarray>) keepPos:<boolean>-- mapped 

Gets and sets the inheritance flags for the specified node as a <bitarray>.

If a bit is on, the corresponding inheritance is turned on. The order of the bits is: #{POS_X,POS_Y,POS_Z,ROT_X,ROT_Y,ROT_Z,SCALE_X,SCALE_Y,SCALE_Z}

If keepPos:false is specified, the node might move when an inheritance is turned on or off.

getTransformLockFlags <node> -- mapped 
setTransformLockFlags <node> (#all|#none| <bitarray>)-- mapped 

Gets and sets the transform lock flags for the specified node as a <bitarray>.

If a bit is on, the corresponding transform lock is turned on. The order of the bits is: #{POS_X,POS_Y,POS_Z,ROT_X,ROT_Y,ROT_Z,SCALE_X,SCALE_Y,SCALE_Z}.

If #all is specified, all locks will be checked.

If #none is specified, all locks will be unchecked.

See How To ... Develop A Transform Lock Script for an example.

Miscellaneous Node Methods

classOf <node> 

Returns the class of the world state of the node (the state of the node at the top of its stack). If no modifiers are applied to the base object, the class returned is the class of the base object. If modifiers are applied to the base object, the class returned is the class of the node as it exits the last modifier. For example, if you apply a Bend modifier to a Box, the Bend modifier converts the incoming Box primitive to a mesh, and the class returned by classOf is Editable_Mesh. You can get the class of the base object in all cases by using classOf <node>.baseObject .

isPointSelected <node> <point_index> 

Returns true if the specified point is selected, false if not.

The definition of a 'point' varies depending on the object type.

For meshes, it is the mesh vertex.

For NURBS objects, it is the vertex or control point.

For a spline, it is the knot and its In and Out bezier handles. The spline will appear to have three times more knots and if a knot is selected, its bezier handles will also be considered selected. Thus, the <point_index> must be multiplied by three to query the correct knot value. For example, if in an Editable Spline knot 1 is selected and knot 2 is not, indices 1, 2, and 3 will all return True, indices 4, 5, and 6 will return False.

pointSelection <node> <point_index> 

Returns a floating point weighted point selection if the object supports soft selections. Most object types just return 1.0 if the point is selected and 0.0 if not. Only NURBS, Editable Mesh, and Editable Polyobjects currently support weighted point selection.

nodeInvalRect <node> 

Invalidates the rectangle in the viewports that the node is occupying. Rectangles flagged as invalid will be updated on the next screen redraw.

stopCreating <node> 

This method stops the creation of the current object, if any. This method is primarily used to ensure that a NURBS object is fully created, which until the creation is stopped. This method will also deactivate any activated object create buttons in the Create panel.

Associated Methods

uniqueName <prefix> [numDigits:<integer>] 

Generates a unique scene node name from a prefix string by adding a series of digits in the same manner as 3ds Max does as you create objects in the scene. This name is only guaranteed to be unique until the next scene node creation.

The numDigits: optional keyword argument available since 3ds Max 2011 controls the number of digits to be used.

When not supplied, it defaults to three digits in 3ds Max 2011 and higher.

In releases prior to 3ds Max 2011, the number of digits was two.

FOR EXAMPLE

   $Box001.name = uniqueName "MyRenamedBox"
   -->"MyRenamedBox001"