Mesh

class Mesh(GraphicEntity)

Introduced in DXF version R13 (AC1012), dxftype is MESH.

3D mesh entity similar to the Polyface entity. Create Mesh in layouts and blocks by factory function add_mesh().

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

Since ezdxf v0.8.9 Mesh stores vertices, edges, faces and creases as packed data (array.array()).

DXF Attributes for Mesh

Common DXF Attributes for DXF R13 or later

Mesh.dxf.version
Mesh.dxf.blend_crease

0 = off, 1 = on

Mesh.dxf.subdivision_levels

int >= 0, 0 = no smoothing

Mesh Methods

Mesh.edit_data()

Context manager various mesh data, returns MeshData.

MeshData

class MeshData
MeshData.vertices

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

MeshData.faces

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

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

MeshData.edges

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

Each edge consist of exact two vertex indices (= index in MeshData.vertices).

MeshData.edge_crease_values

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

MeshData.add_face(vertices)

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

MeshData.add_edge(vertices)

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

MeshData.optimize(precision=6)

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