Path¶
This module implements a geometrical Path
supported by several render backends,
with the goal to create such paths from LWPOLYLINE, POLYLINE and HATCH boundary paths
and send them to the render backend, see ezdxf.addons.drawing
.
Minimum common interface:
 matplotlib: PathPatch
matplotlib.path.Path() codes:
MOVETO
LINETO
CURVE4  cubic Bèziercurve
 PyQt: QPainterPath
moveTo()
lineTo()
cubicTo()  cubic Bèziercurve
 PyCairo: Context
move_to()
line_to()
curve_to()  cubic Bèziercurve
 SVG: SVGPath
“M”  absolute move to
“L”  absolute line to
“C”  absolute cubic Bèziercurve
ARC and ELLIPSE entities are approximated by multiple cubic Béziercurves, which are close enough for display rendering. Nonrational SPLINES of 3rd degree can be represented exact as multiple cubic Béziercurves, other Bsplines will be approximated.

class
ezdxf.render.path.
Path
¶ 

is_closed
¶ Returns
True
if the start point is close to the end point.

classmethod
from_lwpolyline
(lwpolyline: LWPolyline) → Path¶ Returns a
Path
from aLWPolyline
entity, all vertices transformed to WCS.

classmethod
from_polyline
(polyline: Polyline) → Path¶ Returns a
Path
from aPolyline
entity, all vertices transformed to WCS.

classmethod
from_ellipse
(ellipse: Ellipse, segments: int = 1) → Path¶

classmethod
from_hatch_polyline_path
(polyline: PolylinePath, ocs: ezdxf.math.ucs.OCS = None, elevation: float = 0) → Path¶

classmethod
from_hatch_edge_path
(edges: EdgePath, ocs: ezdxf.math.ucs.OCS = None, elevation: float = 0) → Path¶

control_vertices
()¶ Yields all path control vertices in consecutive order.

has_clockwise_orientation
() → bool¶ Returns
True
if 2D path has clockwise orientation, ignores zaxis of all control vertices.

line_to
(location: Vector)¶ Add a line from actual path end point to location.

curve_to
(location: Vector, ctrl1: Vector, ctrl2: Vector)¶ Add a cubic Bèziercurve from actual path end point to location, ctrl1 and ctrl2 are the control points for the cubic Bèziercurve.

close
() → None¶ Close path by adding a line segment from the end point to the start point.

add_curves
(curves: Iterable[Bezier4P])¶ Add multiple cubic Bèziercurves to the path.
Autodetect if the path end point is connected to the start or end point of the curves, if none of them is close to the path end point a line from the path end point to the curves start point will be added.

add_ellipse
(ellipse: ConstructionEllipse, segments=1)¶ Add an elliptical arc as multiple cubic Bèziercurves, use
from_arc()
constructor of classConstructionEllipse
to add circular arcs.Autodetect connection point, if none is close a line from the path end point to the ellipse start point will be added (see
add_curves()
).By default the start of an empty path is set to the start point of the ellipse, setting argument reset to
False
prevents this behavior. Parameters
ellipse – ellipse parameters as
ConstructionEllipse
objectsegments – count of Bèziercurve segments, at least one segment for each quarter (pi/2),
1
for as few as possible.reset – set start point to start of ellipse if path is empty

add_spline
(spline: BSpline, level=4)¶ Add a Bspline as multiple cubic Bèziercurves.
Nonrational Bsplines of 3rd degree gets a perfect conversion to cubic bezier curves with a minimal count of curve segments, all other Bspline require much more curve segments for approximation.
Autodetect connection point, if none is close a line from the path end point to the spline start point will be added (see
add_curves()
).By default the start of an empty path is set to the start point of the spline, setting argument reset to
False
prevents this behavior. Parameters
spline – Bspline parameters as
BSpline
objectlevel – subdivision level of approximation segments
reset – set start point to start of spline if path is empty

transform
(m: Matrix44) → Path¶ Returns a new transformed path.
 Parameters
m – transformation matrix of type
Matrix44

approximate
(segments: int) → Iterable[Vector]¶ Approximate path by vertices, segments is the count of approximation segments for each cubic bezier curve.
