Node Common Properties, Operators, and Methods

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

Quick Page Navigation - Jump To:

Methods

Render-Related Methods

Group-Related Methods

Node Viewport State Methods

Node Selection Methods

Modifier Stack Related Methods

Node Modifier Transform Methods

Node Conversion Methods

Node Utility Methods

Node User Properties

Inverse Kinematics Properties

Miscellaneous Methods

Constructors

<non_wild_card_pathname>

identifies a unique node in the scene

<objectset>[<integer>]

<wild_card_pathname>[<integer>]

n'th scene object in collection

<node_constructor> [ name: <string> ] \

[ prefix: <string> ] \

[ material: <material> ] \

[ target: <node> ] \

[ pos: <point3> ] \ -- default [0,0,0]

[ position: <point3> ] \ -- synonym for pos

[ rotation: <quat> ] \ -- default 0 rotation

[ scale: <point3> ] \ -- default 100% scale

[ pivot: <point3> ] \ -- default normal node pivot location

[ transform: <matrix3> ] \ -- default identity

[ isSelected: <boolean> ] \ -- default false

[ dir: <point3> ] -- set local z direction

The position and rotation values are relative to the current active grid if 'coordsys grid' is the current working coordinate system.

A <node_constructor> is one of the scene node classes listed in Node Subclasses, such as box, sphere, quadPatch, splineShape, etc.

For example:

b = box name:"foo" position:[10,10,10] height:20

All of the node constructors can take the above optional keyword arguments, along with any of general node properties or any of the properties for the particular node class as keyword arguments.

The name keyword can be used to specify the name for the created node. 3ds Max allows the same name to be used for more than one node.

The prefix keyword can be used in place of the name keyword argument to specify the start of the node name from which 3ds Max will generate a unique name by adding a series of digits, as it does when creating objects interactively.

For example:

for i in 1 to 100 do sphere prefix:"baz"

--creates 100 spheres, giving each a unique name

--beginning with "baz", such as $baz01, $baz02, $baz03, etc.

 

The material keyword can be used to apply the specified material to the created node.

The target keyword can be used to automatically apply a LookAt controller to the node's transform track, and set the specified node as the LookAt target.

The transformation arguments, pos, scale, rotation, and pivot, are applied to the new object in the order they are specified in the constructor call, so you can control transform order. The pos, scale, and rotation arguments are mutually exclusive with the transform argument which can be used as an alternative way to set the node's complete transform matrix in one go.

Notes:

Exercise care if you specify the target keyword. When you specify a target object, 3ds Max stores with the target object the last object it was assigned as a target of. If you delete the target object, the behavior of 3ds Max is to also delete the object looking at it. If the target object is a targetobject class object, deleting an object looking at it will also delete the target object, even if another object is also looking at it.

The performance of iterating and indexing the 'selection' and '$' object sets has been substantially improved in 3ds Max 4. In versions prior 3ds Max 4, the whole scene was traversed looking for selected nodes when indexing, iterating or snapshotting into an array, causing big delays in large scenes. Now, the 'selection' object set uses direct access to the SDK explicit current selection set.

Properties

See General Node Properties and Node Transform Properties for details about the properties accessible on scene nodes.

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 which 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 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 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:, etc.

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

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, etc. 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.

 

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 2 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 would be 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 (ie. loft of a donut).

isSurfaceUVClosed <node> <surface_index_integer>

Returns a 2 element array indicating if the parametric surface is closed in the U and V dimensions (ie. 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 1 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 instead. 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 notify 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):

Example:

mapped fn TMInvalidate obj =

 ( at time (currenttime-1) obj.transform

  nodeInvalRect obj

  invalidateTreeTM obj

  redrawViews()

 )

 

invalidateWS <node> -- mapped

Invalidates the node's world space cache.

 

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

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

ignoreCase specifies whether the comparisons should be case sensitive or not. When set to true, non-case-sensitive comparison will be 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 on, 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 2 nodes called "AA" and "aa", and you say: '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

Get and set the inheritance flags for the specified node as an <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 may move when an inheritance is turned on or off.

getTransformLockFlags <node> -- mapped

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

Set and set the transform lock flags for the specified node as an <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 instead, all locks will be checked. If #none is specified, all locks will be unchecked.

Render-Related Methods

getInheritVisibility <node>

Returns true if the node inherits the visibility of its parent object (if any), false if not.

setInheritVisibility <node> <boolean>

Sets whether the node inherits the visibility of its parent object (if any). If <boolean> is true, node inherits visibility. If <boolean> is false the node does not inherit visibility.

getVisController <node>

Returns an instance of the node's visibility controller. Returns undefined if the node does not have a visibility track.

getImageBlurMultController <node>

Returns the node's Image Motion Blur Multiplier controller. Returns undefined if not Image Motion Blur Multiplier controller has been assigned to the node.

setImageBlurMultiplier <node> <time> <number>

Sets the node's Image Motion Blur Multiplier value at the specified time to the specified value

setImageBlurMultController <node> <controller>

Sets the node's Image Motion Blur Multiplier controller to the specified controller

setMotBlur <node> <integer>

Sets which type of motion blur to use for node. If <integer> = 1, None. If <integer> = 2, Object Motion Blur. If <integer> = 3, Image Motion Blur.

setRenderable <node> <boolean>

Sets whether the node is renderable. If <boolean> is true, node is renderable. If <boolean> is false the node is not renderable.

getRenderID <node>

Returns the RenderID of the node. A value of 65535 is returned if the scene has not yet been rendered, or the node is not renderable. The RenderIDs of the nodes are output to the NODE_RENDER_ID g-buffer channel by the renderer.

setRenderID <node> <integer>

Sets the RenderID of the node to the specified value. This value is not "sticky" - it is not saved with the scene, and it will be replaced by the renderer when the next render occurs.

Group-Related Methods

group <node_collection> [ name:<string> ] [ prefix:<string> ] \

[ select:<boolean> ]

Makes a group of the given nodes and returns the group node. You can optionally specify the group name or group name prefix. Not specifying a name or specifying a group name prefix ensures that the group name assigned is unique. Specifying select:true selects the group after it is made.

For example:

group $box* name:"boxes" --makes a group of all box*'s named "boxes".

group selection --groups current selection.

 

ungroup <group_head_node> -- mapped

Ungroups one level of a group node.

For example:

ungroup $group01 --ungroups group $group01

 

explodeGroup <group_head_node> -- mapped

Ungroups all levels in a group node.

isGroupHead <node>

Returns true if node is group head, false otherwise.

isGroupMember <node>

Returns true if node is in a group, false otherwise.

isOpenGroupMember <node>

Returns true if <node> is a member of a group, and that group is open.

isOpenGroupHead <node>

Returns true if <node> is the head of a group, and that group is open.

setGroupOpen <group_head_node> <boolean>

Sets whether the group is set as open or closed. If <boolean> is true, the group is set as open. If <boolean> is false the group is closed.

WARNING! Use the following methods with care. You can place nodes in states that are impossible to accomplish using the 3ds Max user interface.

 

setGroupMember <node> <boolean>

Sets whether the node is a group member or not. If <boolean> is true, node is set as a group member. If <boolean> is false, and the node is a group member, the node is set as not being a group member and is unlinked from the group head.

Note:

If you set a node to be a group member using this method, you need to set the node to be a child of a group head. Otherwise, the node name is not shown in the Select By Name dialog.

For example:

setGroupHead $dummy01 true

append $group03.children $dummy01

setGroupHead <node> <boolean>

Sets whether the node is flagged as a group head or not. If <boolean> is true, node is flagged as a group head. If <boolean> is false, the node is set as not being a group head.

Note:

If you flag a node as a group head using this method, the node's mesh will not be displayed in the viewports, and its properties will not be shown in the Modify panel. If you flag a group head node as not being a group head using this method, you will not be able to Open or Explode the group via the Group menu command.

Example

-- create a set of spheres, group them, and test group head and member of group

mySpheres=for i=1 to 5 collect sphere pos:(random [-100,-100,0] [100,100,0])

group MySpheres name:"MyGroup"

isGroupHead $MyGroup -- returns true

isGroupMember $sphere01 -- returns true

-- check to see if group is open. Open group and test member of group

isOpenGroupHead $MyGroup -- returns false

setGroupOpen $MyGroup true

isOpenGroupMember $sphere01 -- returns false

-- create a new set of spheres, append the group to the set, and then group them all

NewSpheres=for i=1 to 3 collect sphere pos:(random [-100,-100,0] [100,100,0])

append NewSpheres $MyGroup

group NewSpheres name:"BiggerGroup"

-- open the group head, test member of group, and then close the groups.

setGroupOpen $BiggerGroup true

isOpenGroupMember $MyGroup

setGroupOpen $MyGroup false

setGroupOpen $BiggerGroup false

Node Viewport State Methods

hide <node> -- mapped

Hides the specified node or node collection.

unhide <node> [doLayer:<boolean>] -- mapped

Unhides the specified node or node collection.

If the optional doLayer keyword is set to true and the node is in a layer that is hidden, the entire layer is unhidden. When false (the default), just the node is unhidden.

freeze <node> -- mapped

Freezes the specified node or node collection.

unfreeze <node> [doLayer:<boolean>] -- mapped

Unfreezes the specified node or node collection.

If the optional doLayer keyword is set to true and the node is in a layer that is frozen, the entire layer is unfrozen. When false (the default), just the node is unfrozen.

flagForeground <node> <boolean> -- mapped

Controls the disposition of scene nodes in the viewport foreground/background planes, so you can influence interactive performance on a node. Nodes placed in the foreground plane are redrawn individually and so interactive changes to them through spinners in scripted rollout panels are much faster.

The boolean argument puts the scene node(s) into the foreground plane if true, or into the background plane if false. You should be judicious in putting nodes in the foreground plane, because putting too many objects in the foreground plane reduces the foreground plane's effectiveness. Remember to unflag objects when you don't need to interactively control them any more.

getTrajectoryOn <node>

Returns true if Trajectory is shown for the node, false otherwise.

setTrajectoryOn <node> <boolean>

Sets whether Trajectory is shown for the node. If <boolean> is true, Trajectory is shown. If <boolean> is false, Trajectory is not shown.

isBoneOnly <node>

Returns true if the node's showLinksOnly property is true.

getCVertMode <node>

Returns true if node is displayed using vertex colors in shaded viewports, false otherwise.

setCVertMode <node> <boolean>

Sets whether to display the effect of assigned vertex colors for the node in shaded viewports. If <boolean> is true, node is displayed using vertex colors. If <boolean> is false, node is displayed using the material or wireframe color.

getShadeCVerts <node>

Returns true if the vertex color display for the node is shaded in the viewports, false otherwise.

setShadeCVerts <node> <boolean>

Sets whether the vertex color display for the node is shaded in the viewports. When true, the colors are unshaded and appear in their pure RGB values. When false, the colors appear like any other assigned color in the viewports.

Node Selection Methods

clearSelection()

clearNodeSelection [ redraw:<boolean> ]

Deselects all currently selected scene nodes. Scene is redrawn unless redraw:false is specified.

deselect <node> -- mapped

Deselects the given node(s).

For example:

deselect $box* --deselects all items whose names start with "box".

 

deselectNode <node>

Deselects a single node

select <node> -- mapped

Deselects any currently selected objects and then selects the node(s) you specified.

selectMore <node> -- mapped

Adds the node(s) to the set of selected objects. If you want to build a set of selected objects from scratch in a loop, you can use clearSelection() to clear the selection before entering the loop, and use selectMore() in the loop to add objects to the set of selected objects.

Modifier Stack Related Methods

validModifier [ <node> | <objectset> | <group> ] <modifier | modifier_class>

Tests whether a particular modifier or modifier class may be added the given <node> or to all of the objects in the objectset or group. Returns true if so, false if not.

The validModifier() method operates exactly as does the Modify panel in determining modifier applicability. Any modifier that takes a deformable object will return true for all scene objects except Helpers. This corresponds to the Modify panel's behavior of allowing modifiers such as Bend, Taper, etc. to be applied to lights and cameras, space warp objects, etc., as well as geometry types like box, sphere, etc., but not helpers such as dummys or bones.

The validModifier() method will return true if an empty <objectset> is specified, or if a <group> is specified and the modifier is valid for all members of the group. In these cases, applying the modifier using the addModifier() method will fail, because the <objectset> is empty in the first case, or because the modifier cannot be applied to the dummy object that is the parent object of the objects in the group. You will need to test for these conditions in your script, or use the modPanel.addModToSelection() method described in Modify Panel.

addModifier <node> <modifier> [before:index] -- mapped

Applies the modifier to all instances of the node(s) to which the function is applied. The optional before: keyword argument can be used to insert the modifier into the node's modifier stack just before the indexed modifier, counting from the top of the stack.

Since 3ds Max 3, addModifier() does not preserve the sub-object selection that might be active in the modifier stack when adding the modifier. If you want to add a modifier and preserve the sub-object selection, use the modPanel.addModToSelection() method described in Modify Panel.

If <node> is a collection, an instance of the modifier is placed on each of the nodes in the collection. Unlike interactively applying a modifier to a selection, the position and size of each modifier instance's gizmo corresponds to position and size of the node the modifier instance is applied to. To apply a modifier to a collection in the same manner that 3ds Max applies modifiers, use the modPanel.addModToSelection() method described in Modify Panel.

Also see Modifier and SpacewarpModifier for more details.

deleteModifier <node> <modifier_or_index> -- mapped

Lets you delete modifiers from the modifier stack. Takes either a modifier value which is present on the <node> stack, or an index specifying the index of the modifier to delete, counting from the top of the stack.

collapseStack <node> -- mapped

Collapses the modifiers out of a stack, leaving a resultant editable base object corresponding to the class of the node(s) on top of their stack. If there are no modifiers in the stack when this is called, no action is taken. If you want to force an object to be an editable mesh, use the function convertToMesh().

Node Modifier Transform Context Methods

getModContextTM <node> <modifier>

Returns a Matrix3 value giving the modifier's context transform for the local coordinates used in modifier sub-object gizmos. Accessing the transform properties of a modifier sub-object such as a gizmo or a center in MAXScript yields values that are relative to that modifier's context transform, equivalent to the values shown in track view for those properties. If the modifier is not operating on a sub-object selection, such as a face or vertex selection, or if the modifier was interactively applied to an object selection, this context TM is the local coordinate space of the object itself. However, if the modifier is operating on either an object selection set or a sub-object selection, the context transform gives the position and orientation of that selection, and so you can use the getModContextTM() function to get the world-space transform properties of any of its sub-objects.

getModContextBBoxMin <node> <modifier>

getModContextBBoxMax <node> <modifier>

These functions complement the getModContextTM() function and can be used to derive the world-space coordinates of the bounding box of the modifier context. This can be used, for example, to determine the bounds of a modifier operating on a sub-selection or the bounds of an FFD lattice. This is particularly useful for scripting FFD control point placement, since these control points live in a 0-to-1 lattice space—the mod context bounding box gives the world space bounds of this lattice space allowing you to compute scaled lattice space coordinates from world coordinates. The functions return Point3 values for the minimum and maximum extents of the bounding box.

See Modifier Sub-Object Transform Properties for examples of using the above methods.

Node Conversion Methods

convertToMesh <node> -- mapped

This function converts appropriate scene object types into Editable Meshes. It is similar to collapseStack() in that it will remove all modifiers present, but unlike collapseStack() it will always replace the base object with an editable mesh version, even if there are no modifiers present.

convertToMesh() can be applied to any object that an Edit Mesh modifier can work on, such as geometry and shapes, but not helpers, space warps, lights, etc. If the object cannot be converted, the function returns undefined.

convertToSplineShape <node> -- mapped

Converts the given scene node to a SplineShape object. If the object cannot be converted (typically, if it is not a shape), the function returns undefined. Any modifiers present will be collapsed. The collapseStack() function can also be used as can the collapse button in the modifier stack dialog in 3ds Max; both generate a SplineShape, but will only do so if there is at least one modifier present.

canConvertTo <node> <class>

Allows you to test whether a given node is convertible into a given class. Returns true or false.

For example:

if canConvertTo $foo NURBSSurface then ...

The kinds of classes you can convert objects to are the generic editable forms including Mesh, SplineShape, NURBSCurve, NURBSSurface, etc.

convertTo <node> <class> -- mapped

This function is a general form of the existing specific conversion functions such as convertToMesh(), convertToSplineShape(), etc.

convertToSplineShape() can be written:

For example

convertTo $circle01 SplineShape

If the conversion is not supported, the function returns the value undefined.

convertToNURBSSurface <node> -- mapped

convertToNURBSCurve <node> -- mapped

These functions work on those primitive geometry and shape classes that support conversion to NURBS (such as boxes, spheres, circles, lines, etc.). If an object does not support conversion, the function returns undefined.

Node Utility Methods

isDeleted <MAXWrapper_object>

This function yields the result true if the object has been deleted and false if it still exists in the scene. Using the function only makes sense in situations where references to 3ds Max objects are held in variables or arrays or passed as parameters and you want to determine whether the object has been deleted from the scene. Performing an operation on a deleted 3ds Max object referenced in a variable or array otherwise generates an exception. Any kind of 3ds Max object can be tested in this way, scene objects, modifiers, controllers, materials, etc.

For example:

sel = selection as array -- snapshot selection

...

-- <one or more objects in the selection are deleted,

-- by the user or other scripts>

...

for obj in sel

where not isDeleted obj do

move obj [10,0,0]

When a node has been deleted,

<node> == undefined returns false

<node> != undefined returns true,

Example:

if mynode != undefined and not isdeleted myNode do ...

 

distance <node> <node>

Computes the distance between the pivot points of the two specified nodes.

intersectRay <node> <ray>

Computes the closest intersection of the ray and the surface of the given node. Returns another Ray which defines the position of intersection in 3D space and the surface normal direction vector at that point. The intersection test respects the face normals of the node, i.e. if a face's normal points away from the ray's source, an intersection test is not performed on that face. intersectRay() works if the world state of the node (the state of the node at the top of the node's stack) has a surface, such as an editable mesh, a Standard, Extended, or Compound Primitive, or a Patch or NURBS surface object. Splines and NURBS curves do not have a surface. Returns undefined if the ray doesn't intersect the node, the faces it does intersect point away from the ray's position, or the node does not have a surface.

intersectRayEx <node> <ray>

Takes a ray and computes the closest intersection to the surface of the given node. It returns an array with the following three elements.

  1. A Ray defining the position of intersection in 3-space and the surface normal direction vector at the point.

  2. The index of the face the ray intersects with

  3. The barycentric coordinates of the face that was hit.

This method only works if the world state of the node is a mesh, either because it started as an editable mesh or because it has modifiers applied that convert the node to a mesh. Unlike intersectRay(), this method will not work if the node is a Standard or Extended Primitive - the node's stack must evaluate to a mesh. The intersection test respects the face normals of the node, i.e. if a face's normal points away from the ray's source, an intersection test is not performed on that face. Returns undefined if the ray doesn't intersect the node, the faces it does intersect point away from the ray's position, or the node isn't a mesh.

What are Barycentric Coordinates?

Barycentric coordinates are the coordinates relative to the triangular face. The barycentric coordinates of a point p relative to a triangle describe that point as a weighted sum of the vertices of the triangle.

If the barycentric coordinates are b0, b1, and b2, then:

p = b0*p0 + b1*p1 + b2*p2;

where p0, p1, and p2 are the positions of the vertices of the triangle. The Point3 returned by this method has the barycentric coordinate stored in its three component values. The coordinate is relative to the triangular face that was intersected. Barycentric coordinates can also be used to interpolate any quantity whose value is known at the vertices of the triangle.

Following is an example of finding the UV coordinates at the intersection point:

Example:

s = sphere material:(standardMaterial diffuseMap:(checker()))

showTextureMap s.material s.material.diffuseMap on

--

-- Add a normal modifier to make the sphere into a mesh

addModifier s (normalModifier())

r = ray [-100,5,0] (s.center-[-100,5,0])

--

-- Get the Intersection details

arr = (intersectRayEx s r)

--

-- Create a dummy at the point of intersection

dummy pos:(arr[1]).pos

--

-- Get the texture face

tf = getTVFace s arr[2]

--

-- Get the UVW verts of the face

tv1 = getTVert s tf.x

tv2 = getTVert s tf.y

tv3 = getTVert s tf.z

--

-- Calculate the texture vertices at point of intersection from

-- the barycentric coordinates

tv = tv1*arr[3].x + tv2*arr[3].y + tv3*arr[3].z

--

-- Delete the modifier

deleteModifier s 1

 

intersects <node> <node>

Returns true if the bounding boxes of the two specified nodes overlap, or false if they do not overlap.

printStack <node>

Prints a representation of the current modifier stack for the given node.

Node User Properties

getUserProp <node> <key_string>

Retrieves the node's user property with the given key as a string. <key_string> is either a String or a Name value. If the key does not exist, a value of undefined is returned.

setUserProp <node> <key_string> <value>

Sets the node's user property with the given key to the given value.

getUserPropBuffer <node>

Retrieves the entire user property buffer as a string containing all the user property settings. This is effectively the contents of the User Defined Properties box in the 3ds Max Object Properties dialog.

setUserPropBuffer <node> <string>

Sets the user property buffer to the given string.

See Node User-Defined Properties and Methods for more information on these methods.

Inverse Kinematics Properties

The following methods get and set the node's IK values as seen in the Hierarchy panel, Object Parameters rollout.

getRotTaskWeight <node>

Returns the rotation binding weight for the node.

setRotTaskWeight <node> <float>

Sets the rotation binding weight for the node.

getPosTaskWeight <node>

Returns the position binding weight for the node.

setPosTaskWeight <node> <float>

Sets the position binding weight for the node.

getTaskAxisState <node> <pos_or_rot_integer> <axis_integer>

Returns true or false to indicate if the specified axis is turned on for position or rotation binding. If an axis is turned off, the specified axis is no longer influenced by the follow object or the IK Controller Position end effector. <pos_or_rot_integer> sets whether the method returns the position state or the rotation state: 0 specifies position; 1 specifies rotation. <axis_integer> sets the axis to check: 0 specifies X, 1 specifies Y, 2 specifies Z.

setTaskAxisState <node> <pos_or_rot_integer> <axis_integer> <boolean>

Sets the axis state for position or rotation binding to the specified boolean value. See getTaskAxisState() for a description of the parameters.

mirrorIKConstraints <node> <axis_integer> <pos_or_rot_integer>

Mirrors the specified IK constraints on the specified node's transform controller about the specified axis. <axis_integer> specifies the axis of reflection: 0 for X, 1 for Y, 2 for Z. <pos_or_rot_integer> specifies which type of constraints are being mirrored: 0 for position, 1 for rotation.

nodeIKParamsChanged <node>

Call this method when one of the node level IK parameters has been changed.

OKToBindToNode <ik_node> <node>

Returns true if the <ik_node> can be bound to the <node> as a follow object, false otherwise. If the <ik_node> is not part of an IK system, this method always returns true. This method tests <node> to see if its transform is in any way already dependent on the IK system, and returns false if it is.

Miscellaneous 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 a spline, it is the knot. For NURBS objects, it is the vertex or control point.

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 and Editable Mesh objects currently support weighted point selection.

nodeInvalRect <node>

Invalidates the rectangle in the viewports that the node is occupying. Rectangles flagged as invalid will be update 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 objects is fully created, which it until the creation is stopped. This method will also deactivated any activated object create buttons in the Create panel.

Associated Methods

uniqueName <prefix>

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

For example:

$foo.name = uniqueName "foo"

See also

MAXWrapper Common Properties, Operators, and Methods

Value Common Properties, Operators, and Methods

General Node Properties

Node Transform Properties

Node User-Defined Properties and Methods

Nested Object Properties

Class and Object Inspector Functions

Dynamic Properties

Node Subclasses

NURBS Node Properties and Methods