BMesh Types (bmesh.types)

class bmesh.types.BMEdge

The BMesh edge connecting 2 verts

calc_face_angle()
Returns:The angle between 2 connected faces in radians.
Return type:float
calc_length()
Returns:The length between both verts.
Return type:float
copy_from(other)

Copy values from another element of matching type.

hide_set(hide)

Set the hide state. This is different from the hide attribute because it updates the selection and hide state of assosiated geometry.

Parameters:hide (boolean) – Hidden or visible.
normal_update()

Update edges vertex normals.

other_vert(vert)

Return the other vertex on this edge or None if the vertex is not used by this edge.

Parameters:vert (BMVert) – a vert in this edge.
Returns:The edges other vert.
Return type:BMVert or None
select_set(select)

Set the selection. This is different from the select attribute because it updates the selection state of assosiated geometry.

Parameters:select (boolean) – Select or de-select.

Note

Currently this only flushes down, so selecting a face will select all its vertices but de-selecting a vertex won’t de-select all the faces that use it, before finishing with a mesh typically flushing is still needed.

hide

Hidden state of this element.

Type :boolean
index

Index of this element.

Type :int

Note

This value is not necessarily valid, while editing the mesh it can become dirty.

It’s also possible to assign any number to this attribute for a scripts internal logic.

To ensure the value is up to date - see BMElemSeq.index_update.

is_boundary

True when this edge is at the boundary of a face (read-only).

Type :boolean
is_manifold

True when this edge is manifold (read-only).

Type :boolean
is_valid

True when this element is valid (hasn’t been removed).

Type :boolean
is_wire

True when this edge is not connected to any faces (read-only).

Type :boolean

Faces connected to this edge, (read-only).

Type :BMElemSeq of BMFace

Loops connected to this edge, (read-only).

Type :BMElemSeq of BMLoop
seam

Smooth state of this element.

Type :boolean
select

Selected state of this element.

Type :boolean
smooth

Smooth state of this element.

Type :boolean
tag

Generic attribute scripts can use for own logic

Type :boolean
verts

Verts this edge uses (always 2), (read-only).

Type :BMElemSeq of BMVert
class bmesh.types.BMEditSelIter
class bmesh.types.BMEditSelSeq
add(element)

Add an element to the selection history (no action taken if its already added).

clear()

Empties the selection history.

remove(element)

Remove an element from the selection history.

validate()

Ensures all elements in the selection history are selected.

active

The last selected element or None (read-only).

Type :BMVert, BMEdge or BMFace
class bmesh.types.BMElemSeq

General sequence type used for accessing any sequence of BMVert, BMEdge, BMFace, BMLoop.

When accessed via BMesh.verts, BMesh.edges, BMesh.faces there are also functions to create/remomove items.

get(verts, fallback=None)

Return a face/edge which uses the verts passed.

Parameters:
  • verts (BMVert) – Sequence of verts.
  • fallback – Return this value if nothing is found.
index_update()

Initialize the index values of this sequence.

This is the equivalent of looping over all elements and assigning the index values.

for index, ele in enumerate(sequence):
    ele.index = index

Note

Running this on sequences besides BMesh.verts, BMesh.edges, BMesh.faces works but wont result in each element having a valid index, insted its order in the sequence will be set.

new(co=(0.0, 0.0, 0.0), example=None)

Vertex Sequence

Parameters:
  • co (float triplet) – The initial location of the vertex (optional argument).
  • example (BMVert) – Existing vert to initialize settings.
Returns:

The newly created edge.

Return type:

BMVert

new(verts, example=None)

Edge Sequence

Parameters:
  • verts (pair of BMVert) – Vertex pair.
  • example (BMEdge) – Existing edge to initialize settings (optional argument).
Returns:

The newly created edge.

Return type:

BMEdge

new(verts, example=None)

Face Sequence

Create a new vert/edge/face.

Parameters:
  • verts (BMVert) – Sequence of 3 or more verts.
  • example (BMFace) – Existing face to initialize settings (optional argument).
Returns:

The newly created face.

Return type:

BMFace

remove(elem)

Remove a vert/edge/face.

class bmesh.types.BMFace

The BMesh face with 3 or more sides

calc_area()

Return the area of the face.

Returns:Return the area of the face.
Return type:float
calc_center_bounds()

Return bounds center of the face.

Returns:a 3D vector.
Return type:mathutils.Vector
calc_center_median()

Return median center of the face.

Returns:a 3D vector.
Return type:mathutils.Vector
copy(verts=True, edges=True)

Make a copy of this face.

Parameters:
  • verts (boolean) – When set, the faces verts will be duplicated too.
  • edges (boolean) – When set, the faces edges will be duplicated too.
Returns:

The newly created face.

Return type:

BMFace

copy_from(other)

Copy values from another element of matching type.

copy_from_face_interp(face)

Interpolate the customdata from another face onto this one (faces should overlap).

Parameters:face (BMFace) – The face to interpolate data from.
hide_set(hide)

Set the hide state. This is different from the hide attribute because it updates the selection and hide state of assosiated geometry.

Parameters:hide (boolean) – Hidden or visible.
normal_update()

Update faces normal.

select_set(select)

Set the selection. This is different from the select attribute because it updates the selection state of assosiated geometry.

Parameters:select (boolean) – Select or de-select.

Note

Currently this only flushes down, so selecting a face will select all its vertices but de-selecting a vertex won’t de-select all the faces that use it, before finishing with a mesh typically flushing is still needed.

edges

Edges of this face, (read-only).

Type :BMElemSeq of BMEdge
hide

Hidden state of this element.

Type :boolean
index

Index of this element.

Type :int

Note

This value is not necessarily valid, while editing the mesh it can become dirty.

It’s also possible to assign any number to this attribute for a scripts internal logic.

To ensure the value is up to date - see BMElemSeq.index_update.

is_valid

True when this element is valid (hasn’t been removed).

Type :boolean
loops

Loops of this face, (read-only).

Type :BMElemSeq of BMLoop
normal

The normal for this face as a 3D, wrapped vector.

Type :mathutils.Vector
select

Selected state of this element.

Type :boolean
smooth

Smooth state of this element.

Type :boolean
tag

Generic attribute scripts can use for own logic

Type :boolean
verts

Verts of this face, (read-only).

Type :BMElemSeq of BMVert
class bmesh.types.BMIter

Internal BMesh type for looping over verts/faces/edges, used for iterating over BMElemSeq types.

class bmesh.types.BMLoop

This is normally accessed from BMFace.loops where each face corner represents a corner of a face.

calc_angle()

Return the angle at this loops corner of the face. This is calculated so sharper corners give lower angles.

Returns:The angle in radians.
Return type:float
calc_normal()

Return normal at this loops corner of the face. Falls back to the face normal for straignt lines.

Returns:a normalized vector.
Return type:mathutils.Vector
calc_tangent()

Return the tangent at this loops corner of the face (pointing inward into the face). Falls back to the face normal for straignt lines.

Returns:a normalized vector.
Return type:mathutils.Vector
copy_from(other)

Copy values from another element of matching type.

copy_from_face_interp(face, vert=True, multires=True)

Interpolate the customdata from a face onto this loop (the loops vert should overlap the face).

Parameters:
  • face (BMFace) – The face to interpolate data from.
  • vert (boolean) – When enabled, interpolate the loops vertex data (optional).
  • multires (boolean) – When enabled, interpolate the loops multires data (optional).
edge

The loops edge (between this loop and the next), (read-only).

Type :BMEdge
face

The face this loop makes (read-only).

Type :BMFace
index

Index of this element.

Type :int

Note

This value is not necessarily valid, while editing the mesh it can become dirty.

It’s also possible to assign any number to this attribute for a scripts internal logic.

To ensure the value is up to date - see BMElemSeq.index_update.

is_valid

True when this element is valid (hasn’t been removed).

Type :boolean

The next face corner (read-only).

Type :BMLoop

The previous face corner (read-only).

Type :BMLoop

Loops connected to this loop, (read-only).

Type :BMElemSeq of BMLoop
tag

Generic attribute scripts can use for own logic

Type :boolean
vert

The loops vertex (read-only).

Type :BMVert
class bmesh.types.BMVert

The BMesh vertex type

calc_edge_angle()

Return the angle between 2 connected edges.

Returns:The angle between both edges in radians.
Return type:float
copy_from(other)

Copy values from another element of matching type.

copy_from_face_interp(face)

Interpolate the customdata from a face onto this loop (the loops vert should overlap the face).

Parameters:face (BMFace) – The face to interpolate data from.
copy_from_vert_interp(vert_pair, fac)

Interpolate the customdata from a vert between 2 other verts.

Parameters:vert_pair (BMVert) – The vert to interpolate data from.
hide_set(hide)

Set the hide state. This is different from the hide attribute because it updates the selection and hide state of assosiated geometry.

Parameters:hide (boolean) – Hidden or visible.
normal_update()

Update vertex normal.

select_set(select)

Set the selection. This is different from the select attribute because it updates the selection state of assosiated geometry.

Parameters:select (boolean) – Select or de-select.

Note

Currently this only flushes down, so selecting a face will select all its vertices but de-selecting a vertex won’t de-select all the faces that use it, before finishing with a mesh typically flushing is still needed.

co

The coordinates for this vertex as a 3D, wrapped vector.

Type :mathutils.Vector
hide

Hidden state of this element.

Type :boolean
index

Index of this element.

Type :int

Note

This value is not necessarily valid, while editing the mesh it can become dirty.

It’s also possible to assign any number to this attribute for a scripts internal logic.

To ensure the value is up to date - see BMElemSeq.index_update.

is_manifold

True when this vertex is manifold (read-only).

Type :boolean
is_valid

True when this element is valid (hasn’t been removed).

Type :boolean
is_wire

True when this vertex is not connected to any faces (read-only).

Type :boolean

Edges connected to this vertex (read-only).

Type :BMElemSeq of BMVert

Faces connected to this vertex (read-only).

Type :BMElemSeq of BMFace

Loops that use this vertex (read-only).

Type :BMElemSeq of BMLoop
normal

The normal for this vertex as a 3D, wrapped vector.

Type :mathutils.Vector
select

Selected state of this element.

Type :boolean
tag

Generic attribute scripts can use for own logic

Type :boolean
class bmesh.types.BMesh

The BMesh data structure

clear()

Clear all mesh data.

copy()
Returns:A copy of this BMesh.
Return type:BMesh
free()

Explicitly free the BMesh data from memory, causing exceptions on further access.

Note

The BMesh is freed automatically, typically when the script finishes executing. However in some cases its hard to predict when this will be and its useful to explicitly free the data.

from_mesh(mesh, use_shape_key=False, shape_key_index=0)

Initialize this bmesh from existing mesh datablock.

Parameters:
  • mesh (Mesh) – The mesh data to load.
  • use_shape_key (boolean) – Use the locations from a shape key.
  • shape_key_index (int) – The shape key index to use.
from_object(mesh, apply_modifiers=True)

Initialize this bmesh from existing object datablock.

Parameters:
  • object (Object) – The object data to load.
  • apply_modifiers (boolean) – Use the final display mesh rather then the deformed cage.
normal_update(skip_hidden=False)

Update mesh normals.

Parameters:skip_hidden (boolean) – When True hidden elements are ignored.
select_flush(select)

Flush selection, independent of the current selection mode.

Parameters:select (boolean) – flush selection or de-selected elements.
select_flush_mode()

flush selection based on the current mode current BMesh.select_mode.

to_mesh(mesh)

Writes this BMesh data into an existing Mesh datablock.

Parameters:mesh (Mesh) – The mesh data to write into.
transform(matrix, filter=None)

Transform the mesh (optionally filtering flagged data only).

Parameters:
  • matrix (4x4 mathutils.Matrix) – transform matrix.
  • filter (set) – set of values in (‘SELECT’, ‘HIDE’, ‘SEAM’, ‘SMOOTH’, ‘TAG’).
edges

This meshes edge sequence (read-only).

Type :BMElemSeq
faces

This meshes face sequence (read-only).

Type :BMElemSeq
is_valid

True when this element is valid (hasn’t been removed).

Type :boolean
is_wrapped

True when this mesh is owned by blender (typically the editmode BMesh).

Type :boolean
select_history

Sequence of selected items (the last is displayed as active).

Type :BMEditSelSeq
select_mode

The selection mode, values can be {‘VERT’, ‘EDGE’, ‘FACE’}, can’t be assigned an empty set.

Type :set
verts

This meshes vert sequence (read-only).

Type :BMElemSeq

Previous topic

BMesh Module (bmesh)

Next topic

BMesh Utilities (bmesh.utils)