Polyline¶
The POLYLINE entity (POLYLINE DXF Reference) is very complex, it’s used to build 2D/3D polylines,
3D meshes and 3D polyfaces. For every type exists a different wrapper class but they all have the
same dxftype of 'POLYLINE'
. Detect POLYLINE type by Polyline.get_mode()
.
POLYLINE types returned by Polyline.get_mode()
:
For 2D entities all vertices in OCS.
For 3D entities all vertices in WCS.
Subclass of 

DXF type 

2D factory function 

3D factory function 

Inherited DXF attributes 
Warning
Do not instantiate entity classes by yourself  always use the provided factory functions!

class
ezdxf.entities.
Polyline
¶ Vertex
entities are stored in a standard Python listPolyline.vertices
. Vertices can be retrieved and deleted by direct access toPolyline.vertices
attribute:# delete first and second vertex del polyline.vertices[:2]

dxf.
elevation
¶ Elevation point, the X and Y values are always
0
, and the Z value is the polyline’s elevation (3D Point in OCS when 2D, WCS when 3D).

dxf.
flags
¶ Constants defined in
ezdxf.lldxf.const
:Value
Description
POLYLINE_CLOSED
1
This is a closed Polyline (or a polygon mesh closed in the M direction)
POLYLINE_MESH_CLOSED_M_DIRECTION
1
equals POLYLINE_CLOSED
POLYLINE_CURVE_FIT_VERTICES_ADDED
2
Curvefit vertices have been added
POLYLINE_SPLINE_FIT_VERTICES_ADDED
4
Splinefit vertices have been added
POLYLINE_3D_POLYLINE
8
This is a 3D Polyline
POLYLINE_3D_POLYMESH
16
This is a 3D polygon mesh
POLYLINE_MESH_CLOSED_N_DIRECTION
32
The polygon mesh is closed in the N direction
POLYLINE_POLYFACE_MESH
64
This Polyline is a polyface mesh
POLYLINE_GENERATE_LINETYPE_PATTERN
128
The linetype pattern is generated continuously around the vertices of this Polyline

dxf.
default_start_width
¶ Default line start width (float); default =
0

dxf.
default_end_width
¶ Default line end width (float); default =
0

dxf.
m_count
¶ Polymesh M vertex count (int); default =
1

dxf.
n_count
¶ Polymesh N vertex count (int); default =
1

dxf.
m_smooth_density
¶ Smooth surface M density (int); default =
0

dxf.
n_smooth_density
¶ Smooth surface N density (int); default =
0

dxf.
smooth_type
¶ Curves and smooth surface type (int); default=0, see table below
Constants for
smooth_type
defined inezdxf.lldxf.const
:Value
Description
POLYMESH_NO_SMOOTH
0
no smooth surface fitted
POLYMESH_QUADRATIC_BSPLINE
5
quadratic Bspline surface
POLYMESH_CUBIC_BSPLINE
6
cubic Bspline surface
POLYMESH_BEZIER_SURFACE
8
Bezier surface

is_2d_polyline
¶ True
if POLYLINE is a 2D polyline.

is_3d_polyline
¶ True
if POLYLINE is a 3D polyline.

is_closed
¶ True
if POLYLINE is closed.

has_arc
¶ Returns
True
if 2D POLYLINE has an arc segment.

get_mode
() → str¶ Returns a string:
'AcDb2dPolyline'
,'AcDb3dPolyline'
,'AcDbPolygonMesh'
or'AcDbPolyFaceMesh'

m_close
(status=True) → None¶ Close POLYMESH in m direction if status is
True
(also closes POLYLINE), clears closed state if status isFalse
.

n_close
(status=True) → None¶ Close POLYMESH in n direction if status is
True
, clears closed state if status isFalse
.

close
(m_close=True, n_close=False) → None¶ Set closed state of POLYMESH and POLYLINE in m direction and n direction.
True
set closed flag,False
clears closed flag.

__getitem__
(pos) → ezdxf.entities.polyline.DXFVertex¶ Get
Vertex
entity at position pos, supportslist
slicing.

points
() → Iterable[ezdxf.math.vector.Vector]¶ Returns iterable of all polyline vertices as
(x, y, z)
tuples, not asVertex
objects.

append_vertex
(point: Vertex, dxfattribs: dict = None) → None¶ Append single
Vertex
entity at location point. Parameters
point – as
(x, y[, z])
tupledxfattribs – dict of DXF attributes for
Vertex
class

append_vertices
(points: Iterable[Vertex], dxfattribs: dict = None) → None¶ Append multiple
Vertex
entities at location points. Parameters
points – iterable of
(x, y[, z])
tuplesdxfattribs – dict of DXF attributes for
Vertex
class

append_formatted_vertices
(points: Iterable[Vertex], format: str = 'xy', dxfattribs: dict = None) → None¶ Append multiple
Vertex
entities at location points. Parameters
points – iterable of (x, y, [start_width, [end_width, [bulge]]]) tuple
format – format: format string, default is
'xy'
, see: User Defined Point Format Codesdxfattribs – dict of DXF attributes for
Vertex
class

insert_vertices
(pos: int, points: Iterable[Vertex], dxfattribs: dict = None) → None¶ Insert
Vertex
entities at location points at insertion position pos` of listPolyline.vertices
. Parameters
pos – insertion position of list
Polyline.vertices
points – list of
(x, y[, z])
tuplesdxfattribs – dict of DXF attributes for
Vertex
class

transform_to_wcs
(ucs: UCS) → Polyline¶ Transform POLYLINE from local
UCS
coordinates to WCS coordinates.New in version 0.11.

virtual_entities
() → Iterable[Union[Line, Arc]]¶ Yields ‘virtual’ parts of POLYLINE as LINE, ARC or 3DFACE entities.
This entities are located at the original positions, but are not stored in the entity database, have no handle and are not assigned to any layout.
New in version 0.12.

explode
(target_layout: BaseLayout = None) → EntityQuery¶ Explode parts of POLYLINE as LINE, ARC or 3DFACE entities into target layout, if target layout is
None
, the target layout is the layout of the POLYLINE.Returns an
EntityQuery
container with all DXF parts. Parameters
target_layout – target layout for DXF parts,
None
for same layout as source entity.
New in version 0.12.

Vertex¶
A VERTEX (VERTEX DXF Reference) represents a polyline/mesh vertex.
Subclass of 

DXF type 

Factory function 

Factory function 

Factory function 

Inherited DXF Attributes 

class
ezdxf.entities.
Vertex
¶ 

dxf.
start_width
¶ Line segment start width (float); default =
0

dxf.
end_width
¶ Line segment end width (float); default =
0

dxf.
bulge
¶ Bulge value (float); default =
0
.The bulge value is used to create arc shaped line segments.

dxf.
flags
¶ Constants defined in
ezdxf.lldxf.const
:Vertex.dxf.flags
Value
Description
VTX_EXTRA_VERTEX_CREATED
1
Extra vertex created by curvefitting
VTX_CURVE_FIT_TANGENT
2
curvefit tangent defined for this vertex. A curvefit tangent direction of 0 may be omitted from the DXF output, but is significant if this bit is set.
VTX_SPLINE_VERTEX_CREATED
8
spline vertex created by splinefitting
VTX_SPLINE_FRAME_CONTROL_POINT
16
spline frame control point
VTX_3D_POLYLINE_VERTEX
32
3D polyline vertex
VTX_3D_POLYGON_MESH_VERTEX
64
3D polygon mesh
VTX_3D_POLYFACE_MESH_VERTEX
128
polyface mesh vertex

dxf.
tangent
¶ Curve fit tangent direction (float), used for 2D spline in DXF R12.

dxf.
vtx1
¶ Index of 1st vertex, if used as face (feature for experts)

dxf.
vtx2
¶ Index of 2nd vertex, if used as face (feature for experts)

dxf.
vtx3
¶ Index of 3rd vertex, if used as face (feature for experts)

dxf.
vtx4
¶ Index of 4th vertex, if used as face (feature for experts)

is_2d_polyline_vertex
¶

is_3d_polyline_vertex
¶

is_polygon_mesh_vertex
¶

is_poly_face_mesh_vertex
¶

is_face_record
¶

Polymesh¶
Subclass of 

DXF type 

Factory function 

Inherited DXF Attributes 

class
ezdxf.entities.
Polymesh
¶ A polymesh is a grid of
m_count
xn_count
vertices, every vertex has its own(x, y, z)
location. ThePolymesh
is an subclass ofPolyline
, DXF type is also'POLYLINE'
butget_mode()
returns'AcDbPolygonMesh'
.
get_mesh_vertex
(pos: Tuple[int, int]) → ezdxf.entities.polyline.DXFVertex¶ Get location of a single mesh vertex.
 Parameters
pos – 0based
(row, col)
tuple, position of mesh vertex

set_mesh_vertex
(pos: Tuple[int, int], point: Vertex, dxfattribs: dict = None)¶ Set location and DXF attributes of a single mesh vertex.
 Parameters
pos – 0based (row, col)tuple, position of mesh vertex
point – (x, y, z)tuple, new 3D coordinates of the mesh vertex
dxfattribs – dict of DXF attributes

get_mesh_vertex_cache
() → ezdxf.entities.polyline.MeshVertexCache¶ Get a
MeshVertexCache
object for this polymesh. The caching object provides fast access to thelocation
attribute of mesh vertices.

MeshVertexCache¶

class
ezdxf.entities.
MeshVertexCache
¶ Cache mesh vertices in a dict, keys are 0based
(row, col)
tuples.Set vertex location:
cache[row, col] = (x, y, z)
Get vertex location:
x, y, z = cache[row, col]

vertices
¶ Dict of mesh vertices, keys are 0based
(row, col)
tuples.

__getitem__
(pos: Tuple[int, int]) → Vertex¶ Get mesh vertex location as
(x, y, z)
tuple. Parameters
pos – 0based
(row, col)
tuple.

__setitem__
(pos: Tuple[int, int], location: Vertex) → None¶ Get mesh vertex location as
(x, y, z)
tuple. Parameters
pos – 0based
(row, col)
tuple.location –
(x, y, z)
tuple

Polyface¶
Subclass of 

DXF type 

Factory function 

Inherited DXF Attributes 
See also

class
ezdxf.entities.
Polyface
¶ A polyface consist of multiple location independent 3D areas called faces. The
Polyface
is a subclass ofPolyline
, DXF type is also'POLYLINE'
butget_mode()
returns'AcDbPolyFaceMesh'
.
append_face
(face: FaceType, dxfattribs: dict = None) → None¶ Append a single face. A face is a list of
(x, y, z)
tuples. Parameters
face – List[
(x, y, z)
tuples]dxfattribs – dict of DXF attributes for
Vertex
entity

append_faces
(faces: Iterable[FaceType], dxfattribs: dict = None) → None¶ Append multiple faces. faces is a list of single faces and a single face is a list of
(x, y, z)
tuples. Parameters
faces – list of List[
(x, y, z)
tuples]dxfattribs – dict of DXF attributes for
Vertex
entity

faces
() → Iterable[List[Vertex]]¶ Iterable of all faces, a face is a tuple of vertices.
 Returns
[vertex, vertex, vertex, [vertex,] face_record]
 Return type
list
