POLYLINE¶
A polyline is a single object that consists of one or (more usefully) multiple linear segments. You can create open or closed regular or irregular polylines.
POLYMESH and POLYFACE are also POLYLINE objects.
Polylines are always 3Dpolylines, 2Dpolylines are not directly supported, but you can modify the created polylines by clearing the flag POLYLINE_3D_POLYLINE to get a 2D polyline.

DXFEngine.
polyline
(points=[], **kwargs)¶ Parameters:  points – list of points, 2D or 3D points, zvalue of 2D points is 0.
 polyline_elevation – polyline elevation (xyztuple), zaxis supplies elevation, x and yaxis has to be 0.)
 flags (int) – polyline flags, bitcoded, default=0
 startwidth (float) – default starting width, default=0
 endwidth (float) – default ending width, default=0
 mcount (int) – polygon mesh M vertex count, default=0
 ncount (int) – polygon mesh N vertex count, default=0
 msmooth_density (int) – (if flagsbit POLYLINE_3D_POLYMESH is set) smooth surface M density, default=0
 nsmooth_density (int) – (if flagsbit POLYLINE_3D_POLYMESH is set) smooth surface N density, default=0 same values as msmooth_density
 smooth_surface (int) – curves and smooth surface type, default=0 ??? see dxfdocumentation
Common Keyword Arguments for all Basic DXF R12 Entities¶
keyword  description 

layer  Layer name as string 
linetype  Linetype name as string, if not defined = BYLAYER 
color  as integer in range [1..255], 0 = BYBLOCK, 256 = BYLAYER 
thickness  Thickness as float 
paper_space  0 = entity is in model_space, 1 = entity is in paper_space 
extrusion_direction  3D Point as tuple(x, y, z) if extrusion direction is not parallel to the World Z axis 
Flags¶
Flag  Description 

POLYLINE_CLOSED  This is a closed Polyline (or a polygon mesh closed in the M direction) 
POLYLINE_MESH_CLOSED_M_DIRECTION  equals POLYLINE_CLOSED 
POLYLINE_CURVE_FIT_VERTICES_ADDED  Curvefit vertices have been added 
POLYLINE_SPLINE_FIT_VERTICES_ADDED  Splinefit vertices have been added 
POLYLINE_3D_POLYLINE  This is a 3D Polyline 
POLYLINE_3D_POLYMESH  This is a 3D polygon mesh 
POLYLINE_MESH_CLOSED_N_DIRECTION  The polygon mesh is closed in the N direction 
POLYLINE_POLYFACE_MESH  This Polyline is a polyface mesh 
POLYLINE_GENERATE_LINETYPE_PATTERN  The linetype pattern is generated continuously around the vertices of this Polyline 
Smooth Density Flags¶
Flag  Description 

POLYMESH_NO_SMOOTH  no smooth surface fitted 
POLYMESH_QUADRIC_BSPLINE  quadratic Bspline surface 
POLYMESH_CUBIC_BSPLINE  cubic Bspline surface 
POLYMESH_BEZIER_SURFACE  Bezier surface 
Methods¶

Polyline.
add_vertex
(point, **kwargs)¶ Add a point to polyline.
Parameters: point – is a 2D or 3D point, zvalue of a 2D point is 0.

Polyline.
add_vertices
(points)¶ Add multiple points.
Parameters: points – list of points, 2D or 3D points, zvalue of 2D points is 0.

Polyline.
close
(status=True)¶ Close Polyline: first vertex is connected with last vertex.
Parameters: status (bool) – True close polyline; False open polyline
Example:
from dxfwrite import DXFEngine as dxf
polyline= dxf.polyline(linetype='DOT')
polyline.add_vertices( [(0,20), (3,20), (6,23), (9,23)] )
drawing.add(polyline)
drawing.save()