Modifier Common Properties, Operators, and Methods

 

   

Modifier Classes - Quick Navigation

Properties

All modifiers have the following properties:

<modifier>.name: string

Get and set modifier name

   

<modifier>.enabled: boolean

<modifier>.enabledInViews: boolean

Lets you control the modifier’s enabled/disabled state. These are read/write properties that let you determine and set the enabled state of the given modifier,

FOR EXAMPLE

$foo.modifiers[2].enabled = false-- turn off 2nd modifier

The enabledInViews property controls viewport display, enabled controls both viewport and rendered display.

   

<modifier>.enabledInRenders: boolean

Get/Set whether the modifier is enabled in renders.

When set to true , the modifier is enabled in renders, when false it is disabled.

   

Associated Methods

The modifier stack on a scene node can be manipulated using the following <node> methods:

validModifier( <node> | <objectset>) (<modifier | <modifier_class>)

Tests whether a particular modifier or modifier class may be added the given <node> or <objectset> . 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.

It is recommended that classes be used in RCMenus and macroScripts using validModifier() to reduce resource usage.

EXAMPLE

if validModifier $ Edit_Mesh then ...

instead of

if validModifier $ (Edit_Mesh()) then ...

The MAXScript isValidModifier function will check if it has been passed a modifier that doesn't exist at runtime. It returns false in this case. It uses the ClassEntry to determine the InputType() of the modifier.

   

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

Adds the modifier to all instances of the node 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.

The added modifier will apply to any appropriate active sub-object selection in the node only if the node is currently selected and open in the Modify panel at the desired sub-object level.

You can use the 3ds Max System global variable, subObjectLevel to test and set the level for the object currently open in the Modify panel.

EXAMPLE

max modify mode-- open mod panel
select $box01-- select box01 into mod panel
subObjectLevel = 3-- subobject level to Face
addModifier $box01 (ffd_2x2x2())-- add FFD mod to those faces

If the before: keyword argument would place a modifier in an invalid position in the stack, the modifier will be placed at the nearest valid position.

For example, if you tried to place a SpacewarpModifier class object below a Modifier class object, the SpacewarpModifier object would be placed below any SpacewarpModifier objects, and above any Modifier objects.

   

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() described in Modify Panel.

   

A limitation of the addModifier() function is that it cannot generally apply modifiers to sub-object selections, and so it disables any current sub-object levels.

To apply a modifier to a sub-object selection in the same manner that 3ds Max applies modifiers, use the modPanel.addModToSelection() .

This function correctly observes the currently selected sub-object level in the Modify panel.

   

deleteModifier <node> <modifier_or_index>

Lets you delete modifiers from the modifier stack.

Takes either a modifier value 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 the appropriate resultant editable base class, such as Editable Mesh, Editable Spline, NURBS Surface, etc., as the base object of the node.

If there are no modifiers in the stack when this is called, no action is taken.

If you want to force a stack collapse or conversion to editable base class form, use one of the node conversion functions, such as convertToMesh(),convertToSplineShape() , etc.

See the methods section in Node Common Properties, Operators, and Methods for more details.

   

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 getModContextTM() 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&emdash;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 Also