Module Mesh :: Class MFaceSeq

Class MFaceSeq

source code

The MFaceSeq object

This object provides sequence and iterator access to the mesh's faces.

Instance Methods
 
extend(vertseq, ignoreDups=True, indexList=True)
Add zero or more faces and edges to the mesh.
source code
 
delete(deledges, faces)
Deletes one or more faces (and optionally the edges associated with the face(s)) from the mesh.
source code
 
sort()
Sorts the faces using exactly the same syntax as pythons own list sorting function.
source code
list of ints
selected()
Get selected faces.
source code
Method Details

extend(vertseq, ignoreDups=True, indexList=True)

source code 
Add zero or more faces and edges to the mesh. Faces which already exist in the mesh, or faces which contain the same vertex multiple times are ignored. Sequences of two vertices are accepted, but no face will be created.
Parameters:
  • vertseq (sequence(s) of MVerts) - either two to four ints or MVerts, or sequence (list or tuple) of sequences each containing two to four ints or MVerts.
  • ignoreDups (boolean) - keyword parameter (default is False). If supplied and True, do not check the input list or mesh for duplicate faces. This can speed up scripts but can prossibly produce undesirable effects. Only use if you know what you're doing.
  • indexList (boolean) - keyword parameter (default is False). If supplied and True, the method will return a list representing the new index for each face in the input list. If faces are removed as duplicates, None is inserted in place of the index.
  • smooth (boolean) - keyword parameter (default is False). If supplied new faces will have smooth enabled.

Note:

Since Blender 2.44 all new faces are selected.

Example:
       import Blender
       from Blender import Mesh

       me = Mesh.Get("Plane")          # get the mesh data called "Plane"
       v = me.verts                    # get vertices
       if len(v) >= 6:                 # if there are enough vertices...
               me.faces.extend(v[1],v[2],v[3]) #   add a single edge
               l=[(v[0],v[1]),[0,2,4,5]]
               me.faces.extend(l)            #   add another face

Warning: Faces using the first vertex at the 3rd or 4th location in the face's vertex list will have their order rotated so that the zero index on in the first or second location in the face. When creating face data with UVs or vertex colors, you may need to work around this, either by checking for zero indices yourself or by adding a dummy first vertex to the mesh that can be removed when your script has finished.

delete(deledges, faces)

source code 
Deletes one or more faces (and optionally the edges associated with the face(s)) from the mesh.
Parameters:
  • deledges (int) - controls whether just the faces (deledges=0) or the faces and edges (deledges=1) are deleted. These correspond to the "Only Faces" and "Edges & Faces" options in the Edit Mode pop-up menu
  • faces (multiple ints or MFaces) - a sequence (list or tuple) containing one or more of:
    • an MEdge belonging to the mesh
    • a integer, specifying an index into the mesh's face list

sort()

source code 

Sorts the faces using exactly the same syntax as pythons own list sorting function.

Example:
       import Blender
       from Blender import Mesh
       me = Mesh.Get('mymesh')
       
       me.faces.sort(key=lambda f: f.area)
       
       me.faces.sort(key=lambda f: f.cent)

Note: Internally faces only refer to their index, so after sorting, faces you alredy have will not have their index changed to match the new sorted order.

selected()

source code 
Get selected faces.
Returns: list of ints
a list of the indices for all faces selected in edit mode.