Meshop Vertex Methods

 

   

Editable Mesh - Quick Navigation

The following methods exposed by the meshOp Struct provide advanced access to the Mesh vertices.

Topic Navigation:  

Mesh Vertex Access

Vertex Color

New Vertices Using Break Chamfer Clone

Delete Vertices

Hidden And Isolated Vertices

Min Vertex Distance From

Move Mesh Vertices

Weld Mesh Vertices

Methods:

Mesh Vertex Access

meshop.getNumVerts <Mesh mesh>

Returns the number of vertices in the mesh.

   

meshop.setNumVerts <Mesh mesh> <int>

Sets the number of vertices in the mesh. Any new vertices are created at [0,0,0] in the mesh's local coordinate system.

   

meshop.getVert <Mesh mesh> <int vertIndex> node:<node=unsupplied>

Returns the position of the specified vertex. If <mesh> is a node, or if <mesh> is an Editable Mesh or a Mesh value and node: is specified, the position returned is in the current coordinate system context. If <mesh> is an Editable Mesh or a Mesh value and node: is not specified, the return value is in the mesh's local coordinate system.

   

meshop.setVert <Mesh mesh> <vertlist> {<point3 pos> | <point3 pos_array>} node:<node=unsupplied>

Moves the specified vertices to the specified position. If <mesh> is a node, or if <mesh> is an Editable Mesh or a Mesh value and node: is specified, the position is in the current coordinate system context. If <mesh> is an Editable Mesh or a Mesh value and node: is not specified, the position is in the mesh's local coordinate system.

The positions can be optionally specified as array. In that case, the number of values in pos_array must match the number of vertices specified in vertlist.

If executed in an animation on context or with the AutoKey button checked, animation keys will be created for the vertices of an Editable Mesh. This is not the case with the original setVert() vertex method available since 3ds Max 2.

Available in 3ds Max 2008 and higher. Previously available in the Avguard Extensions.

NOTE:

It is very important to pass the <vertlist> argument as a bitArray value and not as an array. Passing the argument as an array will cause a significant performance hit (orders of magnitude!)

This applies to all methods operating on sub-object lists.

   

meshop.getVertexAngles <Mesh mesh> <vertlist>

This method calculates, for each vertex, the sum of the angles of this vertex's corner in each face it's on.

So for instance, a point lying in the middle of a grid would always have vertex angle 2*Pi (6.28319 radians, equal to 360 degrees), whereas a corner of a box would only have 3.0/2*Pi (4.71239 radians, equal to 270 degrees).

Returns an array of size=(#vertices in mesh). The array element for any vertices not specified in <vertlist> will contain the value 0.

   

Vertex Color

meshop.getVertsByColor <Mesh mesh> <color color> <float red_thresh> <float green_thresh> <float blue_thresh> channel:<int=0>

Returns the vertices whose vertex color is within the color range as a <bitarray>. The range values shouldbe in the range of 0 to 255.

   

meshop.getVertsByColor <Mesh mesh> <point3 uvw> <Float u_thresh> <Float v_thresh> <Float w_thresh> channel: <int=0>

Returns the vertices whose vertex UVW is within the UVW range as a <bitarray>. The range values shouldbe in the range of 0 to 1.

   

meshop.setVertColor <Mesh mesh> <int mapChannel> <vertlist> <Color color>

Sets the vertex color for the specified vertices in the specified <mapChannel>.

   

New Vertices Using Break, Chamfer, Clone

meshop.breakVerts <Mesh mesh> <vertlist>

For each vertex in <vertlist> , N-1 new vertices are created at the same location, where N is the number of faces using that vertex. Each of these faces will use one of these vertices.

   

meshop.chamferVerts <Mesh mesh> <vertlist> <float amount>

Chamfers the specified vertices by the specified amount.

EXAMPLE:

obj = plane()
convertToMesh obj
max modify mode
select obj
subObjectLevel = 1
meshop.chamferVerts obj #{13} 3.5
 

meshop.cloneVerts <Mesh mesh> <vertlist>

Clones the specified vertices.

   

meshop.detachVerts <Mesh mesh> <vertlist> delete:<boolean=true> asMesh:<boolean=false>

Detaches the faces used by the specified vertices.

If delete: is true , the faces are deleted after being detached.

If delete: is false , the faces are not deleted.

If asMesh: is true , the faces are detached and returned as a Mesh value.

If asMesh: is false , the faces are detached as an element in the mesh and a value of OK is returned.

   

Delete Vertices

meshop.deleteIsoVerts <Mesh mesh>

Deletes all vertices not used by a face.

   

meshop.deleteVerts <Mesh mesh> <vertlist>

Deletes the specified vertices.

   

Hidden And Isolated Vertices

meshop.getHiddenVerts <Mesh mesh>

Returns a bitarray of size=(#vertices inmesh) with bits set for all vertices that are hidden.

   

meshop.setHiddenVerts <Mesh mesh> <vertlist>

Sets the specified vertices as hidden, and non-specified vertices as visible.

EXAMPLE:

obj = plane() --create a plane
convertToMesh obj --convert to Editable_Mesh
--Hide half the vertices
meshop.setHiddenVerts obj #{1..(obj.numverts/2)}
update obj --update the mesh
max modify mode --change to modify mode
select obj --select the plane
subObjectLevel = 1 --switch to vertex level to see the result 
 
meshop.getIsoVerts <Mesh mesh>

Returns a bitarray of size=(#vertices in mesh) with bits set for all vertices that are not used by a face.

EXAMPLE:

obj = plane() --create a plane
$Plane:Plane01 @ [0.000000,0.000000,0.000000]
convertToMesh obj --collapse to Editable_Mesh
$Editable_Mesh:Plane01 @ [0.000000,0.000000,0.000000]
meshop.getIsoVerts obj --Get isolated vertices - none!
#{}
--Delete the 8 faces in the middle of the plane,
--leaving the middle isolated vertex undeleted
meshop.deleteFaces obj #{11..14,19..22} delIsoVerts:false
OK
update obj --update the mesh
OK
meshop.getIsoVerts obj --check the isolated vertices - #13!
#{13}

   

Min. Vertex Distance From...

meshop.minVertexDistanceFrom <Mesh mesh> <int vertIndex> <vertlist>

Returns the minimal distance from <vertIndex> to the vertices specified in <vertlist>.

   

meshop.minVertexDistancesFrom <Mesh mesh> <vertlist> <int iterations>

This function computes distances from selected vertices (as indicated by <vertlist>) to non-selected ones along edge paths. Returns an array of size=(#vertices in mesh). Each element in this array is set to -1 if there is no selection. Otherwise, selected vertices have an array element value of 0; non-selected vertices that are <iterations> or fewer edges away from a selected vertex are assigned the shortest edge-path distance to a selected vertex; and non-selected vertices that are more than <iterations> edges away are set to -1. If <iterations> is 0, the distances are computed from each vertex to the nearest selected vertex, regardless of topology. This is a VERY EXPENSIVE ALGORITHM, which takes almost 4 times as long for twice as many vertices. If <iterations> is non-zero, it represents the number of edges one should "travel" in trying to find the nearest selected vertex—this means that it only takes twice as long for twice as many verts. (This is like the Edge Distance parameter in EMesh's Soft Selection dialog.)

   

Move Mesh Vertices

meshop.moveVert <Mesh mesh> <vertlist> {<point3 offset> | <point3 offset_array>} node:<node=unsupplied> useSoftSel:<bool>

Moves the specified vertices by <offset> .

If <mesh> is a node, or if <mesh> is an Editable Mesh or a Mesh value and node: is specified, the offset is in the current coordinate system context.

If <mesh> is an Editable Mesh or a Mesh value and node: is not specified, the offset is in the mesh's local coordinate system.

In 3ds Max 2008 and higher, this method allows the position to be specified as array. In that case, the number of values in pos_array must match the number of verts specified in vertlist.This feature was previously available in the Avguard Extensions.

If useSoftSel: is true, and the mesh's soft selection data channel is present, the specified offsets are multiplied by the vertex's soft selection value.

NOTE:

It is very important to pass the <vertlist> argument as a bitArray value and not as an array. Passing the argument as an array will cause a significant performance hit (orders of magnitude!)

This applies to all methods operating on sub-object lists.

   

meshop.moveVertsToPlane <Mesh mesh> <vertlist> <point3 normal> <float offset> node:<node=unsupplied>

Moves the specified vertices into the specified plane. The target plane is defined as all points which, when DotProd'd with N, returnthe specifiedoffset.

All vertices are moved along the normal vector N.

If <mesh> is a node, or if <mesh> is an Editable Mesh or a Mesh value and node: is specified, the normal is in the current coordinate system context.

If <mesh> is an Editable Mesh or a Mesh value and node: is not specified, the normal is in the mesh's local coordinate system.

EXAMPLE:

obj = sphere()--create a sphere
convertToMesh obj--convert to Editable_mesh
normal = getNormal obj 10--get the normal of vertex 10
--move all vertices of the mesh to the plane defined by the normal
--vector with an offset of 0.0 (don't offset):
meshop.moveVertsToPlane obj #{1..obj.numverts} normal 0.0
update obj--update the mesh 
 

meshop.makeVertsPlanar <Mesh mesh> <vertlist>

Moves the specified vertices so that they are planar.

   

Weld Mesh Vertices

meshop.weldVertsByThreshold <Mesh mesh> <vertlist> <float threshold>

Welds the specified vertices that are within the threshold distance.

   

meshop.weldVerts

Renamed tomeshOp. weldVertSet

   

meshop.weldVertSet <Mesh mesh> <vertlist> weldpoint:<point3=unsupplied> node:<node=unsupplied>

Welds the specified vertices.

If weldpoint: is specified, the resulting vertex is positioned at the suppliedpoint.

If weldpoint: is not specified, the resulting vertex is positioned at the average location of the specified vertices.

If <mesh> is a node, or if <mesh> is an Editable Mesh or a Mesh value and node: is specified, the position is in the current coordinate system context.

If <mesh> is an Editable Mesh or a Mesh value and node: is not specified, the position is in the mesh's local coordinate system.

   

For more mesh-related methods, see

Editable Mesh - Topics Index

Editable_Mesh : GeometryClass and TriMesh : Value

See Also