Module Mesh :: Class MVertSeq
[hide private]
[frames] | no frames]

Class MVertSeq

source code

The MVertSeq object

This object provides sequence and iterator access to the mesh's vertices. Access and assignment of single items and slices are also supported. When a single item in the vertex list is accessed, the operator[] returns a MVert object which "wraps" the actual vertex in the mesh; changing any of the vertex's attributes will immediately change the data in the mesh. When a slice of the vertex list is accessed, however, the operator[] returns a list of PVert objects which are copies of the mesh's vertex data. Changes to these objects have no effect on the mesh; they must be assigned back to the mesh's vertex list.

Slice assignments cannot change the vertex list size. The size of the list being assigned must be the same as the specified slice; otherwise an exception is thrown.

Example:

       import Blender
       from Blender import Mesh

       me = Mesh.Get("Plane")          # get the mesh data called "Plane"
       vert = me.verts[0]              # vert accesses actual mesh data
       vert.co[0] += 2                 # change the vertex's X location
       pvert = me.verts[-2:]           # pvert is COPY of mesh's last two verts
       pvert[0].co[0] += 2             # change the vertex's X location
       pvert[1].co[0] += 2             # change the vertex's X location
       me.verts[-1] = pvert[1]         # put change to second vertex into mesh

Note: The mesh can be "cleared" by assigning None to the mesh's vertex list. This does not delete the Blender mesh object, it only deletes all the memory allocated to the mesh. The result is equivalent to calling Mesh.New(). The intent is to allow users writing exporters to free memory after it is used in a quick and simple way.

Example:

       import Blender
       from Blender import Mesh

       me = Mesh.Get("Plane")          # get the mesh data called "Plane"
       me.verts = None                 # delete all the mesh's attributes

Instance Methods [hide private]
 
extend(coords)
Append zero or more vertices to the mesh.
source code
 
delete(verts)
Deletes one or more vertices from the mesh.
source code
list of ints
selected()
Get selected vertices.
source code
Method Details [hide private]

extend(coords)

source code 

Append zero or more vertices to the mesh. Unlike MEdgeSeq.extend() and MFaceSeq.extend() no attempt is made to check for duplicate vertices in the parameter list, or for vertices already in the mesh.

Parameters:
  • coords (sequences(s) of floats or vectors) - coords can be
    • a sequence of three floats,
    • a 3D vector, or
    • a sequence (list or tuple) of either of the above.

Note: Since Blender 2.44 all new verts are selected.

Example:

       import Blender
       from Blender import Mesh
       from Blender.Mathutils import Vector

       me = Mesh.Get("Plane")          # get the mesh data called "Plane"
       me.verts.extend(1,1,1)          # add one vertex
       l=[(.1,.1,.1),Vector([2,2,.5])]
       me.verts.extend(l)              # add multiple vertices

delete(verts)

source code 

Deletes one or more vertices from the mesh. Any edge or face which uses the specified vertices are also deleted.

Parameters:
  • verts (multiple ints or MVerts) - can be
    • a single MVert belonging to the mesh (note: will not work with PVerts)
    • a single integer, specifying an index into the mesh's vertex list
    • a sequence (list or tuple) containing two or more of either of the above.

selected()

source code 

Get selected vertices.

Returns: list of ints
a list of the indices for all vertices selected in edit mode.