MAXScript Extensions > MAXScript Extensions for Cloth >

# mCloth : Modifier

    mCloth - superclass: modifier; super-superclass:MAXWrapper - classID:#(685326, 452282)

Value > MAXWrapper > Modifier > mCloth

| Modifier Classes - Quick Navigation

The mCloth modifier implements the MassFX compatible component of the Cloth system of 3ds Max.

Available in 3ds Max 2013 and higher.

Constructor:

    mCloth...

Properties:

## mCloth Simulation Rollout

    <mCloth>.behavior  Integer default: 0; Cloth_behavior

Get/set the state of the "Cloth Behavior" drop-down list.

Possible values are:

0 - Dynamic

1 - Kinematic

    <mCloth>.untilframeenable  Boolean default: False; until_frame

Get/set the state of the "Unit Frame" checkbox.

    <mCloth>.kinematic_until_frame  Float default: 0

Get/set the value of the "Unit Frame" spinner

    <mCloth>.inherit_velocity  Boolean default: False

Get/set the state of the "Inherit Velocity" checkbox.

    <mCloth>.enablelivedrag  Boolean default: False; Enable_Live_Drag

Get/set the state of the "Live Drag" checkbutton.

Currently no effect.

## Forces Rollout

    <mCloth>.do_gravity  Boolean default: True

Get/set the state of the "Use Global Gravity" checkbox.

When set to True, the Gravity settings of the MassFX Dialog will be used.

When set to False, the global Gravity will be ignored.

    <mCloth>.forceList  Array default: #()

Get/set the list of Scene Forces to apply to the Cloth simulation.

## Capture States Rollout

    <mCloth>.showCurrentState  Boolean default: False; Show_Current_State

    <mCloth>.showTargetState  Boolean default: False; Show_Target_State

## Physical Fabric Properties Rollout

    <mCloth>.gravity  Float default: 1.0

Get/set the value of the "Gravity Scale" spinner.

    <mCloth>.density  Float default: 50.0

Get/set the value of the "Density" spinner.

    <mCloth>.stretchiness  Float default: 0.0; Stretching_Stiffness

Get/set the value of the "Stretchiness" spinner.

    <mCloth>.bendiness  Float default: 0.0; Bend_Stiffness

Get/set the value of the "Bendiness" spinner.

    <mCloth>.do_bending_ortho  Boolean default: True

Get/set the state of the "Use Ortho Bending" checkbox.

    <mCloth>.damping_coefficient  Float default: 0.5; Damping

Get/set the value of the "Damping" spinner.

    <mCloth>.friction  Float default: 0.5

Get/set the value of the "Friction" spinner.

    <mCloth>.compressions_limit  Float default: 1.0; compression_limit

Get/set the value of the "Compression > Limit" spinner.

    <mCloth>.compressions_stiffness  Float default: 1.0; compression_stiffness

Get/set the value of the "Compression > Stiffness" spinner.

## Volume Properties Rollout

    <mCloth>.do_pressure  Boolean default: False

    <mCloth>.pressure  Float default: 0.0

## Interaction Rollout

    <mCloth>.self_collision  Boolean default: True; enable_self_collision

Get/set the state of the "Self Collisions" checkbox.

    <mCloth>.self_thickness  Float default: 0.2; Self_Collision_Thickness

Get/set the value of the "Self Thickness spinner.

    <mCloth>.enable_collision  Boolean default: True

Get/set the state of the "Collide To Rigid Objects" checkbox.

    <mCloth>.thickness  Float default: 0.01

Get/set the value of the "Thickness" spinner.

    <mCloth>.two_way_collision  Boolean default: True; do_two_way_collisions

Get/set the state of the "Push Rigid Objects" checkbox.

    <mCloth>.attachToCollide  Boolean default: False; Attach_to_Collide

Get/set the state of the "Attach To Colliders" checkbox.

    <mCloth>.attachment_response_coefficient  Float default: 0.2; attachment_response_coeff

Get/set the value of the "Influence" spinner.

    <mCloth>.attachment_tear_factor  Float default: 1.5

Get/set the value of the "Detach Past" spinner.

## Tearing Rollout

    <mCloth>.tearable  Boolean default: False

Get/set the state of the "Allow Tearing" checkbox.

    <mCloth>.tear_factor  Float default: 1.5

Get/set the value of the "Tear Past" spinner.

    <mCloth>.weldMethod  Integer default: 1; Weld_Method

Get/set the state of the "Weld Prior To Tearing" radio buttons control.

Possible values are:

0 - Vertices

1 - Normals

2 - Don't Weld

## Visualize Rollout

    <mCloth>.showTension  Boolean default: False; Show_Tension

Get/set the state of the "Tension" checkbox.

    <mCloth>.tensionScale  Float default: 1.0; Tension_Scale

Get/set the value of the "Tension" spinner.

## Advanced Rollout

    <mCloth>.do_hard_stretch_limitation  Boolean default: False

Get/set the state of the "Anti-Stretch" checkbox.

    <mCloth>.hard_stretch_limitation  Float default: 1.0

Get/set the value of the "Limit" spinner.

    <mCloth>.com_damping  Boolean default: False; do_com_damping

Get/set the state of the "Use COM Damping" checkbox.

    <mCloth>.hardware  Boolean default: False; do_hardware_simulation

Get/set the state of the "Hardware Acceleration" checkbox.

    <mCloth>.solver_iterations  Integer default: 5

Get/set the value of the "Solver Iter." spinner.

    <mCloth>.Hierarchical_Solver_Iterations  Integer default: 2

Get/set the value of the "Hier. Sol. Iter." spinner.

    <mCloth>.hierarchical_Levels  Integer default: 0

Get/set the value of the "Hier. Levels" spinner.

## Not Exposed To The UI

    <mCloth>.cacheFile  String default: undefined; Cache_File

Get/set the cache file name.

    <mCloth>.simOnRender  Boolean default: False; Simulate_on_Render

Get/set the simulate on render option. Default is False. When set to True, mCloth simulation can be performed before rendering if necessary.

    <mCloth>.do_bending  Boolean default: True

Get/set the state of the Do Bending option. Default is True. When set to False, no bending will be simulated.

    <mCloth>.do_damping  Boolean default: True

Get/set the state of the Do Damping option. Default is True. When set to False, no damping will be performed.

    <mCloth>.do_untangling  Boolean default: False

Get/set whether to perform untangling. Default is False. When set to True, the mCloth will attempt to untangle.

    <mCloth>.do_inter_collision  Boolean default: False

Get/set whether to perform inter-collisions. Default is False. When set to True, the mCloth will calculate inter-collisions.

    <mCloth>.do_adhere  Boolean default: False

Get/set the enabled state of the Adhere option. Default is False. When set to True, the cloth will adhere to rigid bodies it collided with.

    <mCloth>.min_adhere_velocity  Float default: 1.0

Get/set the minimum adhere velocity.

    <mCloth>.do_fluid_collision  Boolean default: False

Get/set the state of the Fluid Collision option. Default is False. When set to True, fluid collisions will be calculated.

    <mCloth>.disable_dynamic_ccd  Boolean default: True

Get/set the disabled state of Dynamic Continuous Collision Detection option. Default is True. When set to False, dynamic CCD will be performed.

    <mCloth>.collision_response_coefficient  Float default: 1.0

Get/set the Collision Response coefficient. This can be used to scale up and down the response to collisions.

    <mCloth>.to_fluid_response_coefficient  Float default: 1.0; to_fluid_response_coeff

Get/set the Collision Response To Fluid coefficient.

    <mCloth>.from_fluid_response_coefficient  Float default: 1.0; from_fluid_response_coeff

Get/set the Collision Response From Fluid coefficient.

    <mCloth>.is_static  Boolean default: False

Get/set the Static state of the mCloth. Default is false.

    <mCloth>.visualization  Boolean default: False

Get/set the enabled state of the Visualization.

    <mCloth>.validbounds  Boolean default: False; do_valid_bounds

Get/set whether to validate bounds.

## Default Group Properties

    <mClothGroup>.useSoftSelection Boolean default: False; Use_Soft_Selection

Get/set the state of the Soft-Selection "Use Soft-Selection" checkbox.

    <mClothGroup>.softselUseEdgeDistance Boolean default: False; Use_Edge_Distance

Get/set the state of the Soft-Selection "Edge Distance" checkbox.

    <mClothGroup>.softselEdgeDist Integer default: 1; Edge_Distance

Get/set the value of the Soft-Selection "Edge Distance" spinner.

    <mClothGroup>.softselAffectBackfacing Boolean default: True; Affect_Backfacing

Get/set the state of the Soft-Selection "Edge Distance" checkbox.

    <mClothGroup>.softselFalloff Float default: 20.0; Falloff

Get/set the value of the Soft-Selection "Falloff" spinner.

    <mClothGroup>.softselPinch Float default: 0.0; Pinch

Get/set the value of the Soft-Selection "Pinch" spinner.

    <mClothGroup>.softselBubble Float default: 0.0; Bubble

Get/set the value of the Soft-Selection "Bubble" spinner.

    <mClothGroup>.useTextureMap Boolean default: False; Use_Texture_Map

Get/set the state of the Soft-Selection "Use Texture Map" checkbox.

    <mClothGroup>.texture Map default: undefined; TextureMap

Get/set the texture map of the Soft-Selection .

    <mClothGroup>.map Integer default: 0; Map_Channel_Type

Get/set the state of the Soft-Selection "Mapping Channel" radio buttons.

Possible values are:

0 - Map

1 - Vertex Color

    <mClothGroup>.mapChannel Integer default: 1; Map_Channel

Get/set the value of the Soft-Selection "Map" spinner.

## Named Point Group Properties

When a named Point Group is created in the mCloth modifier, it will appear as a property of the mCloth with the same name as the group definition, e.g Group001.

Alternatively, you can use the mClothOps Interface's method <mCloth>.getGroupParamBlock <GroupName> to get the Parameter Block of the Group by name and access its properties.

A Group exposes the following properties:

    <mClothGroup>.Active Boolean default: True

Get/set the state of the Group Constraint's "On" checkbox.

    <mClothGroup>.Is_Soft Boolean default: False

Get/set the state of the Group Constraint's "Soft Constraint" checkbox.

    <mClothGroup>.Strength Float default: 100.0

Get/set the value of the Group Constraint's "Strength" spinner.

    <mClothGroup>.Damping Float default: 10.0

Get/set the value of the Group Constraint's "Damping" spinner.

    <mClothGroup>.Use_Edge_Distance Boolean default: False

Get/set the state of the Group Constraint's "Edge Distance" checkbox.

    <mClothGroup>.Edge_Distance Integer default: 1

Get/set the value of the Group's Soft-Selection "Edge Distance" spinner.

    <mClothGroup>.Affect_Backfacing Boolean default: True

Get/set the state of the Group Constraint's "Edge Distance" checkbox.

    <mClothGroup>.Falloff Float default: 20.0

Get/set the value of the Group's Soft-Selection "Falloff" spinner.

    <mClothGroup>.Pinch Float default: 0.0

Get/set the value of the Group's Soft-Selection "Pinch" spinner.

    <mClothGroup>.Bubble Float default: 0.0

Get/set the value of the Group's Soft-Selection "Bubble" spinner.

    <mClothGroup>.Use_Texture_Map Boolean default: False

Get/set the state of the "Use Texture Map" checkbox.

    <mClothGroup>.Map_Channel_Type Integer default: 0

Get/set the Group's Mapping Channel Type.

Possible values are:

0 - Map

1 - Vertex Color

    <mClothGroup>.mapChannel Integer default: 1; Map_Channel

Get/set the Group's Map Channel. Valid values are in the range from 1 to 99.

    <mClothGroup>.Group_Name String default: "Group001"

Get/set the name of the group.

    <mClothGroup>.Offset Float default: 1.0

Get/set the Offset value.

Unexposed to the UI.

    <mClothGroup>.Offset_is_Relative Boolean default: True

Get/set whether the offset is relative or absolute.

Unexposed to the UI.

    <mClothGroup>.Use_Vertex_Colors Boolean default: False

Unexposed to the UI.

## Interface: mclothOps

Methods:

### mCloth ParamBlock2 Access

    <paramBlock2><mCloth>.getObjectParamBlock <node>node

Returns the ParamBlock2 of the mCloth applied to the specified node.

    <paramBlock2><mCloth>.getGroupParamBlock <string>groupname

Returns the ParamBlock2 of the specified named Point Group.

### Point Group Methods

    <integer><mCloth>.numberVertices <node>node

Returns the vertex count of the node the mCloth is applied to.

    <void><mCloth>.selectVertices <bitArray>sel <node>node

Sets the vertex selection to the bitarray specified by the first argument. The second argument is the node the mCloth is applied to.

    <bitArray><mCloth>.getSelectedVertices <node>node

Returns the vertex selection as a bitarray. The argument is the node the mCloth is applied to.

    <integer><mCloth>.makePointGroup <bitArray>vertex_sel <node>node <string>name

Creates a Point Group from the specified vertex selection in the given node and assigns it the name specified by the third argument.

    <void><mCloth>.makeConstraint <string>groupname <string>type <node>target_node

Creates a Constraint from the specified group of the given type using the given node.

    <void><mCloth>.initPointgroup <string>groupname

Initializes the named Point Group.

    <void><mCloth>.detachPointgroup <string>groupname

Detaches the named Point Group.

    <void><mCloth>.deletePointgroup <string>groupname

Deletes the named Point Group.

    <void><mCloth>.makeGroupConstraint <string>groupname <string>target_group

Constrains the group specified by name in the first argument to the target group specified by name in the second argument.

### Simulation Methods

    <void><mCloth>.simulate <boolean>show_dialog

Simulates the mCloth. The boolean argument controls whether the simulation dialog should be shown or not.

    <void><mCloth>.simulateLocal <integer>stop_condition <float>param <boolean>damped

Performs a local simulation with the stop condition specified by the first argument.

    <void><mCloth>.stopLocalSimulation()

Stops the local simulation.

    <void><mCloth>.eraseSimulation()

Erases the simulation data.

    <void><mCloth>.truncateSimulation()

Truncates the simulation.

### Capture State Methods

    <void><mCloth>.setInitialState <node>node

Sets the node's Initial State.

    <void><mCloth>.resetState <node>node

Resets the node's state.

    <void><mCloth>.grabState <node>node

### Cache Methods

    <void><mCloth>.delObjectCache <node>node

Deletes the object cache of the specified node.

    <void><mCloth>.exportCache <node>node <string>filename

Exports the cache of the specified node to the file provided by the second argument.

    <void><mCloth>.importCache <node>node <string>filename

Imports the cache specified by the second argument into the node given by the first argument.

    <void><mCloth>.loadCache <node>node

Loads the cache of the specified node.

    <void><mCloth>.loadAllCaches()

Loads all caches.

    <void><mCloth>.saveCache <node>node

Saves the cache of the specified node.

    <void><mCloth>.saveExtraCache <node>node

Saves the extra cache of the specified node.

    <void><mCloth>.saveAllCaches()

Saves the caches of all nodes.

    <void><mCloth>.saveAllExtraCaches()

Saves the extra caches of all nodes.

    <fpvalue><mCloth>.getObjectProperty <node>node <string>property

Returns the given node's property value. The second argument specifies the property name as string.

    <void><mCloth>.createKeys()

Bakes the simulation to keys.

## Future Methods - Currently Missing Implementation

    <void><mCloth>.setObjectType <node>node <integer>type <boolean>updateSim

Set the Object Type of the specified node to the integer passed as second argument. If the third argument is True, the simulation will be updated.

    <integer><mCloth>.getObjectType <node>node

Get the Object Type as Integer.

    <void><mCloth>.setObjectProperty <node>node <string>property <fpvalue by value>value

Set the Object Property with name specified by the second argument in the node given by the first argument to the value provided by the third argument.

    <TSTR array><mCloth>.showObjectProperties()

Show the Object Properties of the specified node.

    <void><mCloth>.addForceField <node>node

Add Force Field to the specified node.

    <void><mCloth>.removeForceField <node>node

Remove Force Field from the specified node.

    <void><mCloth>.flagParticles <bitArray>sel

Flag the particles specified by the vertex selection bitarray.

    <integer><mCloth>.makeTear <bitArray>vertex_sel <node>node <string>name

Create a Tear using the specified vertex selection bitarray in the node given by the second argument and name the tear using the third argument.

    <void><mCloth>.clearTears <node>node

Clear the Tears definitions in the specified node.