LWPolyline¶
-
class
LWPolyline
(GraphicEntity)¶ Introduced in DXF version R13 (AC1012), dxftype is LWPOLYLINE.
A lightweight polyline is defined as a single graphic entity. The
LWPolyline
differs from the old-stylePolyline
, which is defined as a group of subentities.LWPolyline
display faster (in AutoCAD) and consume less disk space and RAM. CreateLWPolyline
in layouts and blocks by factory functionadd_lwpolyline()
.LWPolyline
is a planar element, therefore all points in OCS as (x, y) tuples (elevation
is the z-axis value).
Bulge Value¶
The bulge value is used to create arc shaped line segments. The bulge 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 (count clockwise)
- negative value (< 0): bulge is left of line (clockwise)
- 0 = no bulge
Start Width 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 vertex has only a meaning if the polyline is closed, and they apply to the last line segment from the last vertex to the first vertex.
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) as tuple
DXF Attributes for LWPolyline¶
-
LWPolyline.dxf.
flags
¶ Constants defined in
ezdxf.const
:LWPolyline.dxf.flags Value Description LWPOLYLINE_CLOSED 1 polyline is closed LWPOLYLINE_PLINEGEN 128 ???
-
LWPolyline.dxf.
const_width
¶ constant line width (float), default=0
-
LWPolyline.dxf.
count
¶ number of vertices (read only), same as
len(polyline)
LWPolyline Attributes¶
-
LWPolyline.
closed
¶ True if polyline is closed else False. A closed polyline has a connection from the last vertex to the first vertex. (read/write)
LWPolyline Methods¶
-
LWPolyline.
get_points
(format='xyseb')¶ Parameters: format – format string, see format codes Returns all polyline points as list of tuples (x, y, start_width, end_width, bulge), format specifies a user defined point format.
start_width, end_width and bulge is 0 if not present (0 is the DXF default value if not present).
All points in OCS as (x, y) tuples (
elevation
is the z-axis value).
-
LWPolyline.
set_points
(points, format='xyseb')¶ Parameters: format – format string, see format codes Replace existing polyline points by new points, points is a list of (x, y, [start_width, [end_width, [bulge]]]) tuples. Set start_width, end_width to 0 to be ignored (x, y, 0, 0, bulge).
All points in OCS as (x, y) tuples (
elevation
is the z-axis value).
-
LWPolyline.
points
(format='xyseb')¶ Parameters: format – format string, see format codes Context manager for polyline points. Returns a standard Python list of points, according to the format string.
All coordinates in OCS.
-
LWPolyline.
vertices
()¶ Yield all polyline points as (x, y) tuples in OCS (
elevation
is the z-axis value).
-
LWPolyline.
append
(point, format='xyseb')¶ Parameters: format – format string, see format codes Append new point, format specifies a user defined point format.
All coordinates in OCS.
-
LWPolyline.
append_points
(points, format='xyseb')¶ Parameters: - points – iterable of point, point is (x, y, [start_width, [end_width, [bulge]]]) tuple
- format – format string, see format codes
Append new points, points is a list of (x, y, [start_width, [end_width, [bulge]]]) tuples. Set start_width, end_width to 0 to be ignored (x, y, 0, 0, bulge).
All coordinates in OCS.
-
LWPolyline.
insert
(pos, point, format='xyseb')¶ Parameters: - pos – insertion position for new point
- point – new polyline point
- format – format string, see format codes
Insert new point in front of position pos, format specifies a user defined point format.
All coordinates in OCS.
-
LWPolyline.
clear
()¶ Remove all points.
-
LWPolyline.
__len__
()¶ Number of polyline points.
-
LWPolyline.
__getitem__
(index)¶ Get point at position index as (x, y, start_width, end_width, bulge) tuple. start_width, end_width and bulge is 0 if not present (0 is the DXF default value if not present), supports extended slicing. Point format is fixed as ‘xyseb’.
All coordinates in OCS.
-
LWPolyline.
__setitem__
(index, value)¶ 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 is 0 by default (straight line). Does NOT support extend slicing. Point format is fixed as ‘xyseb’.
All coordinates in OCS.
-
LWPolyline.
__delitem__
(index)¶ Delete point at position index, supports extended slicing.