The MESH entity (DXF Reference) is a 3D mesh similar to the Polyface entity.

All vertices in WCS as (x, y, z) tuples

Changed in version 0.8.9: Mesh stores vertices, edges, faces and creases as packed data.

Subclass of ezdxf.entities.DXFGraphic
DXF type 'MESH'
Factory function ezdxf.layouts.BaseLayout.add_mesh()
Inherited DXF attributes Common graphical DXF attributes
Required DXF version DXF R2000 ('AC1015')

See also

Tutorial for Mesh and helper classes: MeshBuilder, MeshVertexMerger

class ezdxf.entities.Mesh

0 = off, 1 = on


0 for no smoothing else integer greater than 0.


Vertices as list like VertexArray. (read/write)


Edges as list like TagArray. (read/write)


Faces as list like TagList. (read/write)


Creases as array.array. (read/write)

edit_data() → Iterator[ezdxf.entities.mesh.MeshData]

Context manager various mesh data, returns MeshData.

Despite that vertices, edge and faces since ezdxf v0.8.9 are accessible as packed data types, the usage of MeshData by context manager edit_data() is still recommended.

transform(m: ezdxf.math._matrix44.Matrix44) → ezdxf.entities.mesh.Mesh

Transform the MESH entity by transformation matrix m inplace.


class ezdxf.entities.MeshData

A standard Python list with (x, y, z) tuples (read/write)


A standard Python list with (v1, v2, v3,…) tuples (read/write)

Each face consist of a list of vertex indices (= index in vertices).


A standard Python list with (v1, v2) tuples (read/write). These list represents the edges to which the edge_crease_values values will be applied. Each edge consist of exact two vertex indices (= index in vertices).


A standard Python list of float values, one value for each edge. (read/write)

add_face(vertices: Iterable[Union[Sequence[float], ezdxf.math._vector.Vec2, ezdxf.math._vector.Vec3]]) → Sequence[int]

Add a face by coordinates, vertices is a list of (x, y, z) tuples.

add_edge_crease(v1: int, v2: int, crease: float)

Add an edge crease value, the edge is defined by the vertex indices v1 and v2. The crease value defines the amount of subdivision that will be applied to this edge. A crease value of the subdivision level prevents the edge from deformation and a value of 0.0 means no protection from subdividing.

optimize(precision: int = 6)

Try to reduce vertex count by merging near vertices. precision defines the decimal places for coordinate be equal to merge two vertices.