Point Instance : Modifier

PointInstanceMod - superclass: modifier; super-superclass:MAXWrapper - classID: #(1083403286L, 853173979L)

The Point Instance modifier places instances of one or more scene nodes on the points of a point object. Each targeted point is assigned one of the instanced nodes at random, weighted by each node's probability, and can receive a randomized scale, rotation, and position offset. The modifier works on point objects only (its input type is the Point Object class), and appears in the Points category of the modifier list.

Available in 3ds Max 2027.2 and higher. Static instancing and the viewport and render limits were added in 3ds Max 2027.3; the properties and methods for them are marked below.

Constructor

PointInstanceMod...

Properties

Targeting group

<pointinstancemod>.targeting     Integer    default: 0   --  integer

Gets/sets which points of the incoming point object receive instances, where:

<pointinstancemod>.softThreshold     Float    default: 0.5   --  animatable; float

Gets/sets the soft-selection threshold, in the range 0.0 to 1.0, used when targeting is Soft Selected Points.

<pointinstancemod>.namedSelection     String    default: undefined   --  string

Gets/sets the name of the point named selection to target when targeting is Named Selection.

<pointinstancemod>.targetColor     Color    default: (color 0 0 0)   --  animatable; RGB color

Gets/sets the color to match when targeting is Point Color.

<pointinstancemod>.hue     BooleanClass    default: true   --  boolean

Specifies whether the hue component is compared when matching point colors (the H checkbox).

<pointinstancemod>.saturation     BooleanClass    default: false   --  boolean

Specifies whether the saturation component is compared when matching point colors (the S checkbox).

<pointinstancemod>.value     BooleanClass    default: false   --  boolean

Specifies whether the value (brightness) component is compared when matching point colors (the V checkbox).

<pointinstancemod>.tolerance     Float    default: 10.0   --  animatable; float

Gets/sets the color-matching tolerance, as a percentage in the range 0.0 to 100.0, used by the Point Color targeting modes.

Instances group

<pointinstancemod>.instanceTab     ArrayParameter    default: #()   --  paramBlock2 array

Contains one parameter block per instanced node, holding that node's per-instance settings (see Per-instance properties below).

Note:

Use the PointInstance interface methods below to add and remove instanced nodes, rather than modifying this array directly.

<pointinstancemod>.shapeRandomizationSeed     Integer    default: 12345   --  integer

Gets/sets the random seed, in the range 0 to 9999999, used to choose the instanced node for each point and to randomize scale, rotation, position offset, and time variation.

Display and Rendering group

<pointinstancemod>.displayPoints     BooleanClass    default: true   --  boolean

Specifies whether the points are drawn in the viewport.

<pointinstancemod>.pointSize     Float    default: 5.0   --  float

Gets/sets the viewport display size of the points, in the range 0.0 to 999.9.

<pointinstancemod>.displayIcon     BooleanClass    default: true   --  boolean

Specifies whether the point object's icon is drawn in the viewport.

<pointinstancemod>.iconSize     Float    default: 10.0   --  worldUnits

Gets/sets the size of the point object's icon, in world units.

<pointinstancemod>.instanceDisplay     BooleanClass    default: true   --  boolean

Specifies whether the instances are drawn in the viewport.

<pointinstancemod>.instanceDisplayType     Integer    default: 1   --  integer

Gets/sets how instances are drawn in the viewport, where:

<pointinstancemod>.displayLimit     Integer    default: 25000   --  integer

Gets/sets the maximum number of instances drawn in the viewport, in the range 0 to 99999999 (the Display Limit setting).

<pointinstancemod>.viewportLimitEnabled     BooleanClass    default: false   --  boolean

Specifies whether only a percentage of the points is shown in the viewport. Available in 3ds Max 2027.3 and higher.

<pointinstancemod>.viewportLimitPercent     Float    default: 100.0   --  float

Gets/sets the percentage of points shown in the viewport when viewportLimitEnabled is true, in the range 0.0 to 100.0. Available in 3ds Max 2027.3 and higher.

<pointinstancemod>.renderLimitEnabled     BooleanClass    default: false   --  boolean

Specifies whether only a percentage of the points is rendered. Available in 3ds Max 2027.3 and higher.

<pointinstancemod>.renderLimitPercent     Float    default: 100.0   --  float

Gets/sets the percentage of points rendered when renderLimitEnabled is true, in the range 0.0 to 100.0. Available in 3ds Max 2027.3 and higher.

Other properties

<pointinstancemod>.cacheTypeIndirect     Integer    default: 1   --  integer

This is an internal UI accessor for the cacheType of the instance(s) currently selected in the modifier's UI. Use instanceTab[n].cacheType instead.

Per-instance properties

Each entry of instanceTab is a parameter block with the following properties. Read and set them as <pointinstancemod>.instanceTab[<index>].<property>, for example pim.instanceTab[1].instanceProbability = 60.0.

<instanceTab entry>.instanceNode     UndefinedClass    default: undefined   --  node

The node actually placed on the points. For a dynamic instance this is the source node itself; for a static instance it is a static clone of the source node.

<instanceTab entry>.instanceSourceNode     UndefinedClass    default: undefined   --  node

The source node that this entry instances. This is the node that the PointInstance interface methods look up and return. Available in 3ds Max 2027.3 and higher.

<instanceTab entry>.isStatic     BooleanClass    default: true   --  boolean

Specifies whether the entry is statically instanced (the Static Instance checkbox). A static instance is a clone that is unaffected by later changes to the source node until it is updated (see UpdateNodeStaticInstance). A dynamic instance follows the source node live. Use SetNodeInstanceType or SetNodeInstanceTypeByIndex to change it, so that the static clone is created or removed. Available in 3ds Max 2027.3 and higher. In 3ds Max 2027.2, all entries are dynamic.

<instanceTab entry>.instanceEnable     BooleanClass    default: true   --  boolean

Specifies whether this instanced node is used. Disabled entries are not placed on any points.

<instanceTab entry>.instanceColor     Color    default: (color 0 0 0)   --  RGB color

Gets/sets the entry's swatch color, which is written to the instance color channel of the points that use it. A new entry added through the UI or AddNode gets a random color.

<instanceTab entry>.instanceProbability     Integer    default: 100   --  integer

Gets/sets the relative weight, in the range 0 to 100, with which this node is chosen for each targeted point, compared with the other enabled entries.

<instanceTab entry>.shapeScaleDistribution     Integer    default: 0   --  integer

Gets/sets the scale distribution method, where:

<instanceTab entry>.shapeScaleAxisXAmount     Float    default: 100.0   --  animatable; percent
<instanceTab entry>.shapeScaleAxisYAmount     Float    default: 100.0   --  animatable; percent
<instanceTab entry>.shapeScaleAxisZAmount     Float    default: 100.0   --  animatable; percent

Gets/sets the base scale of the instance along each axis, as a percentage.

<instanceTab entry>.shapeScaleAxisXVariation     Float    default: 0.0   --  animatable; percent
<instanceTab entry>.shapeScaleAxisYVariation     Float    default: 0.0   --  animatable; percent
<instanceTab entry>.shapeScaleAxisZVariation     Float    default: 0.0   --  animatable; percent

Gets/sets the random scale variation along each axis, as a percentage. Each point's scale is the amount plus or minus a random value up to the variation.

<instanceTab entry>.shapeScaleLock     BooleanClass    default: false   --  boolean

Specifies whether the X scale amount and variation are used for all three axes (uniform scaling).

<instanceTab entry>.shapeRotationDistribution     Integer    default: 0   --  integer

Gets/sets the rotation distribution method, where:

<instanceTab entry>.shapeRotationAxisXAmount     Float    default: 0.0   --  animatable; float
<instanceTab entry>.shapeRotationAxisYAmount     Float    default: 0.0   --  animatable; float
<instanceTab entry>.shapeRotationAxisZAmount     Float    default: 0.0   --  animatable; float

Gets/sets the base rotation of the instance about each axis, in degrees.

<instanceTab entry>.shapeRotationAxisXVariation     Float    default: 0.0   --  animatable; float
<instanceTab entry>.shapeRotationAxisYVariation     Float    default: 0.0   --  animatable; float
<instanceTab entry>.shapeRotationAxisZVariation     Float    default: 0.0   --  animatable; float

Gets/sets the random rotation variation about each axis, in degrees (0.0 or greater). Each point's rotation is the amount plus or minus a random value up to the variation.

<instanceTab entry>.shapeRotationLock     BooleanClass    default: false   --  boolean

Specifies whether the X rotation amount and variation are used for all three axes.

<instanceTab entry>.posOffsetType     Integer    default: 0   --  integer

Gets/sets the position offset distribution method, where:

<instanceTab entry>.posOffsetXAmount     Float    default: 0.0   --  animatable; float
<instanceTab entry>.posOffsetYAmount     Float    default: 0.0   --  animatable; float
<instanceTab entry>.posOffsetZAmount     Float    default: 0.0   --  animatable; float

Gets/sets the base offset of the instance from its point along each axis.

<instanceTab entry>.posOffsetXVariation     Float    default: 0.0   --  animatable; float
<instanceTab entry>.posOffsetYVariation     Float    default: 0.0   --  animatable; float
<instanceTab entry>.posOffsetZVariation     Float    default: 0.0   --  animatable; float

Gets/sets the random position offset variation along each axis (0.0 or greater). Each point's offset is the amount plus or minus a random value up to the variation.

<instanceTab entry>.lockPosOffset     BooleanClass    default: false   --  boolean

Specifies whether the X position offset amount and variation are used for all three axes.

<instanceTab entry>.createNamedSelection     BooleanClass    default: false   --  boolean

Specifies whether the points that receive this instance are added to a point named selection, named by namedSelection (the NSel checkbox).

<instanceTab entry>.namedSelection     String    default: ""   --  string

Gets/sets the name of the point named selection created when createNamedSelection is true.

<instanceTab entry>.useTimeScale     BooleanClass    default: false   --  boolean
<instanceTab entry>.timeScaleLo     Float    default: 100.0   --  animatable; float
<instanceTab entry>.timeScaleHi     Float    default: 100.0   --  animatable; float

When useTimeScale is true, each point plays the instance's animation at a random speed between timeScaleLo and timeScaleHi, as a percentage of normal speed.

<instanceTab entry>.useTimeOffset     BooleanClass    default: false   --  boolean
<instanceTab entry>.timeOffset     Float    default: 0.0   --  animatable; float

When useTimeOffset is true, each point's instance animation is shifted by a random offset of up to plus or minus timeOffset frames.

<instanceTab entry>.usePointTime     BooleanClass    default: false   --  boolean
<instanceTab entry>.pointTime     Float    default: 0.0   --  animatable; float

When usePointTime is true, the instance is shown at the fixed frame pointTime on every point.

<instanceTab entry>.useCache     BooleanClass    default: false   --  boolean

Specifies whether the instance's animation is cached, using the method set by cacheType.

<instanceTab entry>.cacheType     Integer    default: 1   --  integer

Gets/sets the animation cache method, where:

<instanceTab entry>.shapeChannelRoutingTab     ArrayParameter    default: #()   --  paramBlock2 array

Contains the entry's channel routings, which map point data channels onto instance attributes. The parameters of each routing entry are not named, so they can't be accessed from MAXScript.

Note:

The time-related properties above (useTimeScale through cacheType) are shown in the Time Controls rollup, which appears only when the 3DSMAX_POINT_TIME_ENABLE environment variable is set to 1. They are still accessible from MAXScript.

PointInstanceMod interfaces

Interface: PointInstance

Methods

<integer>GetNodeCount()

Returns the number of entries in the instanced-node list.

<boolean>AddNode <node>node <&index>indexOut
indexOut is Out parameter

Adds node to the instanced-node list as a new, enabled, statically instanced entry with a random color and a probability of 100. On success, indexOut is set to the 1-based index of the new entry. Returns false, and adds nothing, if node is undefined or is already in the list. Because the entry is static, a hidden copy of node (named <node name>_Clone001, _Clone002, and so on) is added to the scene and used for the instances. Use SetNodeInstanceType false node to switch the entry to a dynamic instance of the original node. In 3ds Max 2027.2, which has no static instancing, AddNode adds a dynamic entry and no copy is created.

<boolean>RemoveNode <node>node

Removes the entry whose source node is node. Returns true on success, or false if node is not in the list.

<boolean>GetNodeIndex <node>node <&index>indexOut
indexOut is Out parameter

If node is the source node of an entry, sets indexOut to that entry's 1-based index and returns true. Otherwise returns false and leaves indexOut unchanged.

<node>GetNodeByIndex <index>index

Returns the source node of the entry at index, or undefined if index is out of range. For a static instance, this is the original node, not its static clone.

<boolean>SetNodeInstanceType <boolean>isStatic <node>node

Sets the entry whose source node is node to static instancing (isStatic true) or dynamic instancing (isStatic false), creating or removing its static clone as needed. Returns true only if the instancing type actually changed. Available in 3ds Max 2027.3 and higher.

<boolean>SetNodeInstanceTypeByIndex <boolean>isStatic <index>index

Works like SetNodeInstanceType, but identifies the entry by its index. Available in 3ds Max 2027.3 and higher.

<boolean>UpdateNodeStaticInstance <node>node

If the entry whose source node is node is statically instanced, rebuilds its static clone to match the current state of the source node (the Update button). Returns true if a static clone was updated. Available in 3ds Max 2027.3 and higher.

<boolean>UpdateNodeStaticInstanceByIndex <index>index

Works like UpdateNodeStaticInstance, but identifies the entry by its index. Available in 3ds Max 2027.3 and higher.

<boolean>IsStaticInstancedNode <node>node

Returns true if node is the source node of a statically instanced entry, and false otherwise (including when node is not in the list). Available in 3ds Max 2027.3 and higher.

<boolean>IsStaticInstancedNodeByIndex <index>index

Returns true if the entry at index is statically instanced, and false otherwise (including when index is out of range). Available in 3ds Max 2027.3 and higher.

FOR EXAMPLE

   -- Three source objects to instance, moved away from the point object
   t = Teapot radius:3 pos:[-150,0,0] name:"InstTeapot"
   b = Box length:5 width:5 height:5 pos:[-150,30,0] name:"InstBox"
   s = Sphere radius:3 pos:[-150,60,0] name:"InstSphere"

   -- A point sphere to place the instances on
   ps = PointSphere radius:50 count:300 name:"InstTarget"
   pim = PointInstanceMod()
   addModifier ps pim

   -- Add the three nodes; each AddNode returns the 1-based index of the new entry
   iT = 0
   pim.AddNode t &iT
   iB = 0
   pim.AddNode b &iB
   iS = 0
   pim.AddNode s &iS
   pim.GetNodeCount()

   -- Pick teapots most often: probabilities 60 / 30 / 10
   pim.instanceTab[iT].instanceProbability = 60.0
   pim.instanceTab[iB].instanceProbability = 30.0
   pim.instanceTab[iS].instanceProbability = 10.0

   -- Give the boxes a random scale variation of 50 percent on X
   pim.instanceTab[iB].shapeScaleAxisXVariation = 50.0

   -- Make the sphere entry dynamic, so later edits to the source sphere update its instances
   pim.SetNodeInstanceTypeByIndex false iS
   #(pim.IsStaticInstancedNode t, pim.IsStaticInstancedNode b, pim.IsStaticInstancedNode s)

   -- Count how many points received each object, using a temporary Edit Point modifier
   em = EditPointMod()
   addModifier ps em
   classof ps
   chId = 0
   em.GetStandardChannelId #InstanceShape ps &chId
   ids = #()
   em.GetActiveIds ps &ids
   vals = #()
   em.GetChannelValues chId ids ps &vals
   for i in #(0, 1, 2) collect (for v in vals where v == i collect v).count
   deleteModifier ps em

OUTPUT:

   3                  -- three entries in the instance list
   #(true, true, false)   -- teapot and box are static (the AddNode default), sphere is dynamic
   #(174, 95, 31)     -- points per object (teapot, box, sphere); the exact numbers vary