A suite of methods provide the ability for a script to invoke Editable Mesh and Edit Mesh Modify panel modes and operations, corresponding to buttons available at various mesh sub-object levels. These methods reside in the meshOps
global structure. These methods effectively "push the button" in the 3ds Max Modify panel. In order to use these methods, the node must be selected and the Modify panel open. In the description of these methods, the first argument <editable_mesh_node_or_modifier>
should be interpreted as either an Editable Mesh node where the modifier stack level is at the base object, or an Edit Mesh modifier where the modifier stack level is at the Edit Mesh. In all cases, the following methods work at the current sub-object level, but only if that level is appropriate for the invoked operation.
This page describes the meshOps structure related to controlling the Modify Panel command modes and operations.For methods directly manipulating vertex, edge and face data, please see the meshOp structure and the Editable_Mesh : GeometryClass and TriMesh : Value topic!
If you have made scripted changes to the mesh you must call the update()
method on the mesh before calling these methods. You do not need to call update()
after just calling one of these methods, as 3ds Max will take care of updating the mesh.
The following methods invoke one of the 'user-interaction' button operations in the Editable Mesh Modify panel, acting on the currently selected sub-objects. These methods highlight the corresponding button in the Edit Geometry rollout and start the operation, at which point the user interactively completes the operation. These methods return after starting the operation, and before the user completes the operation, so care should be taken to ensure that your script does not interfere with the operation. Invoking any of these methods is the same as clicking on the associated button in the Modify panel. Calling a method when the operation is already in effect (either due to a user action or a MAXScript command) causes the operation to be terminated and the highlight is removed from the button.
meshOps.startAttach <editable_mesh_node_or_modifier>
Enters "Attach" command mode - valid in Vertex, Face, Polygon, and Element Sub-Object levels, and when not in Sub-Object mode.
meshOps.startBevel <editable_mesh_node_or_modifier>
Enters "Bevel" command mode - valid in Edge, Face, Polygon, and Element Sub-Object levels.
meshOps.startChamfer <editable_mesh_node_or_modifier>
Enters "Chamfer" command mode - valid in Vertex and Edge Sub-Object levels.
meshOps.startCreate <editable_mesh_node_or_modifier>
Enters "Create" command mode, valid in Vertex, Face, Polygon, and Element Sub-Object levels.
meshOps.startCut <editable_mesh_node_or_modifier>
Enters "Cut" command mode - valid in Edge, Face, Polygon, and Element Sub-Object levels.
meshOps.startDivide <editable_mesh_node_or_modifier>
Divides selected edges into 2 edges, for selected face into 3 faces - valid in Edge, Face, Polygon, and Element Sub-Object levels.
meshOps.startExtrude <editable_mesh_node_or_modifier>
Enters "Extrude" command mode - valid in Face, Polygon, and Element Sub-Object levels.
meshOps.startFlipNormalMode <editable_mesh_node_or_modifier>
Enters "Flip Normal" command mode - valid in Face, Polygon, and Element Sub-Object levels.
meshOps.startSlicePlane <editable_mesh_node_or_modifier>
Enters "Slice Plane" command mode - valid in all Sub-Object levels, and when not in Sub-Object mode.
meshOps.startTurn <editable_mesh_node_or_modifier>
Enters "Turn" command mode - valid in Edge Sub-Object level.
meshOps.startWeldTarget <editable_mesh_node_or_modifier>
Enters "Weld Target" command mode - valid in Vertex Sub-Object level.
The following methods invoke one of the 'instantaneous' button operations in the Editable Mesh Modify panel, acting on the currently selected sub-objects:
meshOps.autoEdge <editable_mesh_node_or_modifier>
Automatically sets the edge visibility on the selected sub-objects - valid in Edge Sub-Object level.
meshOps.break <editable_mesh_node_or_modifier>
Creates a new vertex for each face attached to the selected sub-objects - valid in Vertex Sub-Object level.
meshOps.collapse <editable_mesh_node_or_modifier>
Collapses the selected sub-objects - valid in Vertex, Edge, Face, Polygon, and Element Sub-Object levels.
meshOps.createShapeFromEdges <editable_mesh_node_or_modifier>
Displays Create Shape dialog allowing the user to specify an object name, shape type, and whether to ignore hidden edges. Valid in Edge Sub-Object level.
meshOps.delete <editable_mesh_node_or_modifier>
Deletes the selected sub-objects - valid in Vertex, Face, Polygon, and Element Sub-Object levels.
meshOps.detach <editable_mesh_node_or_modifier>
Displays Detach dialog allowing the user to specify an object name or to detach as element, and whether to clone the selected subobjects. Valid in Vertex, Face, Polygon, and Element Sub-Object levels.
meshOps.explode <editable_mesh_node_or_modifier>
Displays Explode to Objects dialog allowing the user to specify an object name.Explodes the selected faces into multiple elements or objects based on the angles of its edges. Valid in Vertex, Face, Polygon, and Element Sub-Object levels.
meshOps.flipNormal <editable_mesh_node_or_modifier>
Flips the normal of the selected faces - valid in Face, Polygon, and Element Sub-Object levels.
meshOps.gridAlign <editable_mesh_node_or_modifier>
Aligns the selected sub-objects to the construction plane - valid in Vertex, Edge, Face, Polygon, and Element Sub-Object levels.
meshOps.hide <editable_mesh_node_or_modifier>
Hides the selected sub-objects - valid in Vertex, Face, Polygon, and Element Sub-Object levels.
meshOps.invisibleEdge <editable_mesh_node_or_modifier>
Sets selected edges invisible.Valid in Vertex Sub-Object level.
meshOps.makePlanar <editable_mesh_node_or_modifier>
Forces all selected sub-objects to become coplanar - valid in Vertex, Edge, Face, Polygon, and Element Sub-Object levels.
meshOps.removeIsolatedVerts <editable_mesh_node_or_modifier>
Deletes all isolated vertices in the object regardless of the current selection.
meshOps.selectOpenEdges <editable_mesh_node_or_modifier>
Selects all edges with only one face. Valid in Edge Sub-Object level.
meshOps.slice <editable_mesh_node_or_modifier>
Subdivides edges and faces based on Slice Plane. meshOps.startSlicePlane()
must be called to enter the "Slice Plane" command mode before slice
is valid. Valid in all Sub-Object levels, and when not in Sub-Object mode.
meshOps.tessellate <editable_mesh_node_or_modifier>
Tessellates the selected sub-objects - valid in Face, Polygon, and Element Sub-Object levels.
meshOps.unhideAll <editable_mesh_node_or_modifier>
Unhides the hidden sub-objects at the current Sub-Object level - valid in Vertex, Face, Polygon, and Element Sub-Object levels.
meshOps.unifyNormal <editable_mesh_node_or_modifier>
Unifies the normals of the selected faces - valid in Face, Polygon, and Element Sub-Object levels.
meshOps.viewAlign <editable_mesh_node_or_modifier>
Aligns all selected sub-objects to the 0,0,0 plane of the active viewport - valid in Vertex, Edge, Face, Polygon, and Element Sub-Object levels.
meshOps.visibleEdge <editable_mesh_node_or_modifier>
Sets selected edges visible.Valid in Edge Sub-Object level.
meshOps.weld <editable_mesh_node_or_modifier>
Welds the selected vertices - valid in Vertex Sub-Object level.
The meshOps
methods depend on the Modify panel being open and the desired object, either an Editable Mesh base object or Edit Mesh modifier, being currently open in the panel. The meshOps
methods do not perform any operation if these conditions aren't met. You will need to use MAXScript functions like max modify mode
or setCommandPanelTaskMode mode:#modify
to open the Modify panel, select <obj>
to select the object, subObjectLevel = <n>
to set the Sub-Object level, and modPanel.setCurrentObject <obj_or_modifier>
to establish the right context for the new functions to operate. For example:
meshOps.clearAllSG <editable_mesh_node_or_modifier>
Clears all smoothing group assignments for the selected items. Valid in Face, Polygon and Element Sub-Object levels.
meshOps.selectBySG <editable_mesh_node_or_modifier>
Opens the "Select By Smooth Groups" dialog. Valid in Face, Polygon and Element Sub-Object levels.
meshOps.selectByColor <editable_mesh_node_or_modifier>
Selects vertices by color, which is specified in the "Select Vertices By" panel. Valid in Vertex Sub-Object level.
meshOps.showNormal <editable_mesh_node_or_modifier>
Toggles the "Show Normals" checkbox in the Selection panel. Valid for Vertex, Face, Polygon and Element Sub-Object levels.
meshOps.autoSmooth <editable_mesh_node_or_modifier>
Applies auto-smooth to the selected items on the mesh. Equivalent to clicking "Auto Smooth" under "Smoothing Groups". Valid for Face, Polygon, and Element Sub-Object levels.
meshOps.selectByID <editable_mesh_node_or_modifier>
Selects sub-objects by material ID. This is the same as selecting "Select ID" under Surface Properties. If there is a selection, the material ID of the current selection is used, otherwise the default material ID of 1 is selected. Valid for Face, Polygon and Element Sub-Object levels.
meshOps.attachList <editable_mesh_node_or_modifier>
Opens the "Attach List" dialog, to perform an attach operation on a selected list of scene nodes. Only valid in Object level.
EXAMPLE
s=sphere() -- create a sphere ConvertToMesh s -- convert to an Editable Mesh s.selectedfaces=#{1..112} -- select half the faces max modify mode -- open the Modify panel select s -- select the sphere modPanel.setCurrentObject s -- set modifier stack to the base object -- (not really needed in this example) subObjectLevel = 4 -- set Sub-Object level to polygon meshOps.startExtrude s -- start the face extrude command mode, -- highlighting its button in the Edit -- Geometry rollout, at which point the -- user interactively performs the extrude.
ANOTHER EXAMPLE IS
meshOps.Hide (modPanel.getCurrentObject())
which would invoke the Hide button operation on the current object open in the Modify panel if it was an Edit Mesh modifier or Editable Mesh base object.