AffectChannelMod : Modifier

AffectChannelMod - superclass: modifier; super-superclass:MAXWrapper - classID: #(1453030689L, 987447227L)

The Affect Channel modifier (shown in the modifier list as Affect Channel, in the Points category) edits the per-point channel data of a point object through a stack of operations. Operations run in order from first to last. Each one picks a set of target points and reads an optional input channel. It then combines that input with a source coefficient (a constant value, another channel, or a sampled field) using an arithmetic operation or a condition, and writes the result to an output channel. The output channel is created if it does not already exist.

Available in 3ds Max 2027.3 and higher.

Each operation's settings are stored in its own parameter block, not as properties of the modifier. Use the affectChannelInterface methods to add, delete, rename, reorder and look up operations. GetOperationParams() returns an operation's parameter block, whose properties are listed under Operation parameters below.

The operation stack starts empty. A default operation named "Operation 1" is added the first time the modifier is evaluated or its rollup is displayed.

Constructor

AffectChannelMod...

Properties

NOTE

Do not modify the operationParams modifier property or the per-operation operationName property directly. Changing them directly can cause significant problems. Use the affectChannelInterface methods, such as AddOperation(), SetOperationName() and GetOperationParams(), instead.

Display and Rendering group

These properties drive the Display and Rendering rollup, which is the standard point object display rollup hosted on the modifier. They are also saved with presets.

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

Specifies whether the point object's icon is displayed.

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

Gets/sets the display size of the icon, in world units. Range: 0.0 to 1.0E+09.

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

Specifies whether points are displayed in the viewports.

<AffectChannelMod>.pointSize     Float    default: 5.0   --  worldUnits

Gets/sets the display size of points. Range: 0.0 to 1.0E+09.

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

Specifies whether instance geometry assigned to points is displayed.

<AffectChannelMod>.displayLimit     Integer    default: 500   --  integer

Gets/sets the maximum number of instances to display. Range: 0 to 1000000000.

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

Gets/sets how displayed instances are drawn:

Operation parameters

The following properties belong to each per-operation parameter block (AffectChannelOperationParams) returned by affectChannelInterface.GetOperationParams(). They are not properties of the modifier itself. Read and set them directly on the returned block, for example op = m.GetOperationParams 1; op.affectStrength = 0.5.

General

<operationParams>.isOperationActive     BooleanClass    default: true   --  boolean

Specifies whether the operation is evaluated. Inactive operations are skipped. This is the checkbox on each entry in the operation list.

Targeting

<operationParams>.targetType     Integer    default: 0   --  integer

Gets/sets which points the operation affects:

<operationParams>.isInvertedTarget     BooleanClass    default: false   --  boolean

When true, the inverse of the specified target set is used.

<operationParams>.targetSoftSelectionTol     Float    default: 0.5   --  animatable; float

Gets/sets the soft selection threshold used when targetType is 2. Range: 0.0 to 1.0.

<operationParams>.targetNamedSelection     String    default: ""   --  string

Gets/sets the name of the named selection used when targetType is 5.

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

Gets/sets the reference color used when targetType is 6.

<operationParams>.targetColorTol     Float    default: 10.0   --  animatable; float

Gets/sets the color matching tolerance, as a percentage, used when targetType is 6. Range: 0.0 to 100.0.

<operationParams>.useTargetColorHue     BooleanClass    default: true   --  boolean
<operationParams>.useTargetColorSaturation     BooleanClass    default: false   --  boolean
<operationParams>.useTargetColorValue     BooleanClass    default: false   --  boolean

Specify which HSV components (H, S, V) are compared when matching against targetColor.

Input channel

<operationParams>.inputChannelName     String    default: ""   --  string

Gets/sets the short name of the channel the operation reads its input values from. New operations created by AddOperation() set this to the localized string "None", which means no input channel. When no input channel is specified, the values stored in the output channel at the beginning of the operation evaluation take the place of the input channel values. If a name is given and that channel does not exist on the incoming point object, the operation is skipped.

Affect with (source coefficient)

<operationParams>.affectSourceType     Integer    default: 0   --  integer

Gets/sets where the operation's source coefficient comes from:

<operationParams>.affectOperationType     Integer    default: 1   --  integer

Gets/sets the operation category:

The UI drop-down shows Dot Product before Condition. The values above are the ones stored in the parameter.

<operationParams>.affectStrength     Float    default: 1.0   --  animatable; float

Gets/sets the strength of the operation for Value and Channel sources. It applies only to arithmetic operations (not Condition). Range: -1.0E+09 to 1.0E+09.

<operationParams>.affectValueType     Integer    default: 1   --  integer

Gets/sets the data type of the constant source value when affectSourceType is 1 (Value):

<operationParams>.affectValueInteger     Integer    default: 0   --  animatable; integer

Gets/sets the constant source value when affectValueType is 0. Range: -1000000000 to 1000000000.

<operationParams>.affectValueFloat     Float    default: 0.0   --  animatable; float

Gets/sets the constant source value when affectValueType is 1. Range: -1.0E+09 to 1.0E+09.

<operationParams>.affectValuePointX     Float    default: 0.0   --  animatable; float
<operationParams>.affectValuePointY     Float    default: 0.0   --  animatable; float
<operationParams>.affectValuePointZ     Float    default: 0.0   --  animatable; float

Get/set the X, Y and Z components of the constant source value when affectValueType is 2. Range: -1.0E+09 to 1.0E+09.

<operationParams>.affectValueColor     Color    default: (color 255 255 255)   --  animatable; color

Gets/sets the constant source value when affectValueType is 3.

<operationParams>.affectChannelName     String    default: ""   --  string

Gets/sets the short name of the source channel when affectSourceType is 2 (Channel). New operations set this to the localized string "None".

<operationParams>.affectField     UndefinedClass    default: undefined   --  node

Gets/sets the field helper node sampled when affectSourceType is 3 (Field).

<operationParams>.affectFieldMultiplier     Float    default: 1.0   --  animatable; float

Gets/sets the multiplier applied to values sampled from affectField. Range: -1.0E+09 to 1.0E+09.

Condition

<operationParams>.conditionType     Integer    default: 0   --  integer

Gets/sets the comparison used when affectOperationType is 5 (Condition):

<operationParams>.conditionTolerance     Float    default: 0.0   --  animatable; float

Gets/sets the tolerance for the range (+/-) condition. Range: 0.0 to 1.0E+09.

<operationParams>.useConditionPointX     BooleanClass    default: true   --  boolean
<operationParams>.useConditionPointY     BooleanClass    default: true   --  boolean
<operationParams>.useConditionPointZ     BooleanClass    default: true   --  boolean

When the source is a constant Point3 value (affectSourceType 1 and affectValueType 2), specify which of the X, Y and Z components the condition compares. With a vector-valued source channel, all components are compared.

Output channel

<operationParams>.outputChannelName     String    default: "MyChannel"   --  string

Gets/sets the short name of the channel the operation writes to. If the name matches a standard channel, that standard channel is used along with its standard description. Otherwise, a channel that does not exist yet is created with the full name Autodesk User <name> (Autodesk User Default if the name is empty), using outputChannelType and the matching default value.

<operationParams>.outputChannelType     Integer    default: 1   --  integer

Gets/sets the data type of a newly created output channel:

It is ignored when the output channel already exists and isOutputChannelReplaced is false.

<operationParams>.isOutputChannelReplaced     BooleanClass    default: false   --  boolean

When true, a pre-existing output channel is deleted and recreated before the operation runs. Every point's entry is reset to the specified default value, and the channel uses outputChannelType.

<operationParams>.isOutputChannelInternal     BooleanClass    default: false   --  boolean

When true, a newly created output channel is used only inside this modifier (for example, as an intermediate result for later operations) and is not passed up the stack. This applies only to channels that did not already exist. For a pre-existing channel, its existing internal status is kept.

<operationParams>.outputChannelDefaultInteger     Integer    default: 0   --  animatable; integer
<operationParams>.outputChannelDefaultFloat     Float    default: 0.0   --  animatable; float
<operationParams>.outputChannelDefaultPointX     Float    default: 0.0   --  animatable; float
<operationParams>.outputChannelDefaultPointY     Float    default: 0.0   --  animatable; float
<operationParams>.outputChannelDefaultPointZ     Float    default: 0.0   --  animatable; float
<operationParams>.outputChannelDefaultColor     Color    default: (color 255 255 255)   --  animatable; color

Get/set the default value of a newly created output channel. Only the property matching outputChannelType is used. Integer range: -1000000000 to 1000000000. Float/Point3 range: -1.0E+09 to 1.0E+09.

AffectChannelMod interfaces

Interface: affectChannelInterface

A mixin interface (FP_MIXIN) on the modifier. Its methods can be called directly on the modifier (for example, m.AddOperation()) or through the interface (for example, m.affectChannelInterface.AddOperation()). All operation indices are 1-based.

Because a default "Operation 1" can be added as soon as the modifier is evaluated or displayed, do not assume the stack is empty after addModifier. Use the index returned by AddOperation(), or GetOperationIndex, rather than a hard-coded index. The default operation also writes its own output channel (Autodesk User MyChannel) unless you delete or change it.

Point IDs returned by the Editable Point interface (for example by GetActiveIds) are 0-based, unlike MAXScript array indices.

Methods

<index>AddOperation()

Appends a new operation, with default parameters and a unique default name of the form "Operation N", to the end of the operation stack. Returns the 1-based index of the new operation.

<boolean>DeleteOperation <index>indexOperation

Deletes the operation at indexOperation. Later operations move up by one. Returns true if the index was valid and the operation was deleted.

<boolean>SetOperationName <string>operationName <index>indexOperation

Renames the operation at indexOperation. If the name is already used by another operation in the stack, an integer is appended to make it unique. Returns false if the index is invalid or operationName is an empty string.

<index>UpdateOperationOrder <index>indexOperationInit <integer>deltaOperation

Moves the operation at indexOperationInit by deltaOperation positions. Positive values move it later in the stack (evaluated later), negative values move it earlier. The other operations keep their relative order. The move is clamped to the ends of the stack. Returns the operation's new 1-based index. If indexOperationInit is invalid, the stack is unchanged and indexOperationInit is returned.

<integer>GetNumberOfOperations()

Returns the number of operations in the stack.

<index>GetOperationIndex <string>operationName

Returns the 1-based index of the operation named operationName. Operation names are unique within the stack.

<maxObject>GetOperationParams <index>indexOperation

Returns the parameter block for the operation at indexOperation (see Operation parameters), or undefined if the index is invalid. The returned value is a ParamBlock2.

<string>GetOperationName <index>indexOperation

Returns the name of the operation at indexOperation, or an empty string if the index is invalid.

<boolean>LoadPreset <string>name

Loads the named preset, replacing the whole operation stack and the Display and Rendering settings. Returns true on success. Presets are .affectChannelPreset files in an AffectChannelPresets folder. 3ds Max looks in both the factory location (the plugin bundle's Contents\Presets\AffectChannelPresets) and the user location (...\User Settings\AffectChannelPresets). If a user preset has the same name as a factory preset, the user preset wins.

3ds Max 2027 ships with these factory presets:

<boolean>SavePreset <string>name

Saves the current operation stack and Display and Rendering settings as a preset with the given name in the user preset folder. Returns true on success.

<boolean>DeletePreset <string>name

Deletes the named preset. Returns true if the preset was found and deleted.

FOR EXAMPLE

-- Create a point sphere and add an Affect Channel modifier
ps = PointSphere radius:50 count:500
acm = AffectChannelMod()
addModifier ps acm

-- Add an operation that writes the constant 0.25 into a new float channel "Weight" on every point
idx = acm.AddOperation()
acm.SetOperationName "SetWeight" idx
op = acm.GetOperationParams idx
op.targetType = 3            -- All points
op.affectSourceType = 1      -- Value
op.affectOperationType = 0   -- Replace
op.affectValueType = 1       -- Float
op.affectValueFloat = 0.25
op.outputChannelName = "Weight"
op.outputChannelType = 1     -- Float

-- Check the result on a collapsed copy
chk = copy ps
convertTo chk Editable_Point
names = #()
chk.GetAllChannelNames &names
names
chId = 0
chk.GetChannelId "Autodesk User Weight" &chId
ids = #()
chk.GetActiveIds &ids
val = 0.0
chk.GetChannelValue chId ids[1] &val
val

OUTPUT:

#("Autodesk User Weight", "3dsMax Point Positions")
0.25