LWPolyline¶
The LWPOLYLINE entity (DXF Reference) is defined as a single graphic entity, which differs from the
old-style Polyline
entity, which is defined as a group of sub-entities.
LWPolyline
display faster (in AutoCAD) and consume less disk space, it is a planar element,
therefore all points in OCS as (x, y)
tuples (LWPolyline.dxf.elevation
is the z-axis value).
Changed in version 0.8.9: LWPolyline
stores point data as packed data (array.array
).
Subclass of |
|
DXF type |
|
factory function |
|
Inherited DXF attributes |
|
Required DXF version |
DXF R2000 ( |
Bulge value
The bulge value is used to create arc shaped line segments for Polyline
and
LWPolyline
entities. The bulge value defines the ratio of the arc sagitta (versine)
to half line segment length, a bulge value of 1
defines a semicircle.
The sign of the bulge value defines the side of the bulge:
positive value (>
0
): bulge is right of line (counter clockwise)negative value (<
0
): bulge is left of line (clockwise)
0
= no bulge

Start- and end width
The start width and end width values defines the width in drawing units for the following line segment.
To use the default width value for a line segment set value to 0
.
Width and bulge values at last point
The width and bulge values of the last point has only a meaning if the polyline is closed, and they apply to the last line segment from the last to the first point.
See also
User Defined Point Format Codes¶
Code
Point Component
x
x-coordinate
y
y-coordinate
s
start width
e
end width
b
bulge value
v
(x, y [, z]) as tuple
-
class
ezdxf.entities.
LWPolyline
¶ -
-
dxf.
flags
¶ Constants defined in
ezdxf.lldxf.const
:dxf.flags
Value
Description
LWPOLYLINE_CLOSED
1
polyline is closed
LWPOLYLINE_PLINEGEN
128
???
-
dxf.
const_width
¶ Constant line width (float), default value is
0
.
-
dxf.
count
¶ Count of polyline points (read only), same as
len(polyline)
-
closed
¶ True
if polyline is closed. A closed polyline has a connection from the last vertex to the first vertex. (read/write)
-
has_arc
¶ Returns
True
if LWPOLYLINE has an arc segment.
-
has_width
¶ Returns
True
if LWPOLYLINE has any segment with width attributes or DXF attribute const_width != 0.New in version 0.14.
-
__len__
() → int¶ Returns count of polyline points.
-
__getitem__
(index: int) → Tuple[float, float, float, float, float]¶ Returns point at position index as (x, y, start_width, end_width, bulge) tuple. start_width, end_width and bulge is
0
if not present, supports extended slicing. Point format is fixed as'xyseb'
.All coordinates in OCS.
-
__setitem__
(index: int, value: Sequence[float]) → None¶ Set point at position index as (x, y, [start_width, [end_width, [bulge]]]) tuple. If start_width or end_width is
0
or left off the default value is used. If the bulge value is left off, bulge is0
by default (straight line). Does NOT support extend slicing. Point format is fixed as'xyseb'
.All coordinates in OCS.
- Parameters
index – point index
value – point value as (x, y, [start_width, [end_width, [bulge]]]) tuple
-
__delitem__
(index: int) → None¶ Delete point at position index, supports extended slicing.
-
__iter__
() → Iterable[Tuple[float, float, float, float, float]]¶ Returns iterable of tuples (x, y, start_width, end_width, bulge).
-
vertices
() → Iterable[Tuple[float, float]]¶ Returns iterable of all polyline points as (x, y) tuples in OCS (
dxf.elevation
is the z-axis value).
-
vertices_in_wcs
() → Iterable[Vertex]¶ Returns iterable of all polyline points as Vector(x, y, z) in WCS.
-
append
(point: Sequence[float], format: str = 'xyseb') → None¶ Append point to polyline, format` specifies a user defined point format.
All coordinates in OCS.
- Parameters
point – (x, y, [start_width, [end_width, [bulge]]]) tuple
format – format string, default is
'xyseb'
, see: format codes
-
append_points
(points: Iterable[Sequence[float]], format: str = 'xyseb') → None¶ Append new points to polyline, format specifies a user defined point format.
All coordinates in OCS.
- Parameters
points – iterable of point, point is (x, y, [start_width, [end_width, [bulge]]]) tuple
format – format string, default is
'xyseb'
, see: format codes
-
insert
(pos: int, point: Sequence[float], format: str = 'xyseb') → None¶ Insert new point in front of positions pos, format specifies a user defined point format.
All coordinates in OCS.
- Parameters
pos – insert position
point – point data
format – format string, default is ‘xyseb’, see: format codes
-
clear
() → None¶ Remove all points.
-
get_points
(format: str = 'xyseb') → List[Sequence[float]]¶ Returns all points as list of tuples, format specifies a user defined point format.
All points in OCS as (x, y) tuples (
dxf.elevation
is the z-axis value).- Parameters
format – format string, default is
'xyseb'
, see format codes
-
set_points
(points: Iterable[Sequence[float]], format: str = 'xyseb') → None¶ Remove all points and append new points.
All coordinates in OCS.
- Parameters
points – iterable of point, point is (x, y, [start_width, [end_width, [bulge]]]) tuple
format – format string, default is
'xyseb'
, see format codes
-
points
(format: str = 'xyseb') → List[Sequence[float]]¶ Context manager for polyline points. Returns a standard Python list of points, according to the format string.
All coordinates in OCS.
- Parameters
format – format string, see format codes
-
transform
(m: Matrix44) → LWPolyline¶ Transform LWPOLYLINE entity by transformation matrix m inplace.
New in version 0.13.
-
virtual_entities
() → Iterable[Union[Line, Arc]]¶ Yields ‘virtual’ parts of LWPOLYLINE as LINE or ARC 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.
-
explode
(target_layout: BaseLayout = None) → EntityQuery¶ Explode parts of LWPOLYLINE as LINE or ARC entities into target layout, if target layout is
None
, the target layout is the layout of the LWPOLYLINE.Returns an
EntityQuery
container with all DXF parts.- Parameters
target_layout – target layout for DXF parts,
None
for same layoutsource entity. (as) –
-