Trace

This module provides tools to create banded lines like LWPOLYLINE with width information. Path rendering as quadrilaterals: Trace, Solid or Face3d.

class ezdxf.render.trace.TraceBuilder

Sequence of 2D banded lines like polylines with start- and end width or curves with start- and end width.

Note

Accepts 3D input, but z-axis is ignored. The TraceBuilder is a 2D only object and uses only the OCS coordinates!

abs_tol

Absolute tolerance for floating point comparisons

append(trace: AbstractTrace) None

Append a new trace.

close()

Close multi traces by merging first and last trace, if linear traces.

faces() Iterable[Tuple[Vec2, Vec2, Vec2, Vec2]]

Yields all faces as 4-tuples of Vec2 objects in OCS.

faces_wcs(ocs: OCS, elevation: float) Iterable[Sequence[Vec3]]

Yields all faces as 4-tuples of Vec3 objects in WCS.

virtual_entities(dxftype='TRACE', dxfattribs=None, doc: Drawing | None = None) Iterable[Quadrilateral]

Yields faces as SOLID, TRACE or 3DFACE entities with DXF attributes given in dxfattribs.

If a document is given, the doc attribute of the new entities will be set and the new entities will be automatically added to the entity database of that document.

Note

The TraceBuilder is a 2D only object and uses only the OCS coordinates!

Parameters:
  • dxftype – DXF type as string, “SOLID”, “TRACE” or “3DFACE”

  • dxfattribs – DXF attributes for SOLID, TRACE or 3DFACE entities

  • doc – associated document

classmethod from_polyline(polyline: DXFGraphic, segments: int = 64) TraceBuilder

Create a complete trace from a LWPOLYLINE or a 2D POLYLINE entity, the trace consist of multiple sub-traces if bulge values are present. Uses only the OCS coordinates!

Parameters:
  • polylineLWPolyline or 2D Polyline

  • segments – count of segments for bulge approximation, given count is for a full circle, partial arcs have proportional less segments, but at least 3

__len__()
__getitem__()
class ezdxf.render.trace.LinearTrace

Linear 2D banded lines like polylines with start- and end width.

Accepts 3D input, but z-axis is ignored.

abs_tol

Absolute tolerance for floating point comparisons

is_started

True if at least one station exist.

add_station(point: UVec, start_width: float, end_width: float | None = None) None

Add a trace station (like a vertex) at location point, start_width is the width of the next segment starting at this station, end_width is the end width of the next segment.

Adding the last location again, replaces the actual last location e.g. adding lines (a, b), (b, c), creates only 3 stations (a, b, c), this is very important to connect to/from splines.

Parameters:
  • point – 2D location (vertex), z-axis of 3D vertices is ignored.

  • start_width – start width of next segment

  • end_width – end width of next segment

faces() Iterable[Tuple[Vec2, Vec2, Vec2, Vec2]]

Yields all faces as 4-tuples of Vec2 objects.

First and last miter is 90 degrees if the path is not closed, otherwise the intersection of first and last segment is taken into account, a closed path has to have explicit the same last and first vertex.

virtual_entities(dxftype='TRACE', dxfattribs=None, doc: Drawing | None = None) Iterable[Quadrilateral]

Yields faces as SOLID, TRACE or 3DFACE entities with DXF attributes given in dxfattribs.

If a document is given, the doc attribute of the new entities will be set and the new entities will be automatically added to the entity database of that document.

Parameters:
  • dxftype – DXF type as string, “SOLID”, “TRACE” or “3DFACE”

  • dxfattribs – DXF attributes for SOLID, TRACE or 3DFACE entities

  • doc – associated document

class ezdxf.render.trace.CurvedTrace

2D banded curves like arcs or splines with start- and end width.

Represents always only one curved entity and all miter of curve segments are perpendicular to curve tangents.

Accepts 3D input, but z-axis is ignored.

faces() Iterable[Tuple[Vec2, Vec2, Vec2, Vec2]]

Yields all faces as 4-tuples of Vec2 objects.

virtual_entities(dxftype='TRACE', dxfattribs=None, doc: Drawing | None = None) Iterable[Quadrilateral]

Yields faces as SOLID, TRACE or 3DFACE entities with DXF attributes given in dxfattribs.

If a document is given, the doc attribute of the new entities will be set and the new entities will be automatically added to the entity database of that document.

Parameters:
  • dxftype – DXF type as string, “SOLID”, “TRACE” or “3DFACE”

  • dxfattribs – DXF attributes for SOLID, TRACE or 3DFACE entities

  • doc – associated document

classmethod from_arc(arc: ConstructionArc, start_width: float, end_width: float, segments: int = 64) CurvedTrace

Create curved trace from an arc.

Parameters:
  • arcConstructionArc object

  • start_width – start width

  • end_width – end width

  • segments – count of segments for full circle (360 degree) approximation, partial arcs have proportional less segments, but at least 3

Raises:

ValueError – if arc.radius <= 0

classmethod from_spline(spline: BSpline, start_width: float, end_width: float, segments: int) CurvedTrace

Create curved trace from a B-spline.

Parameters:
  • splineBSpline object

  • start_width – start width

  • end_width – end width

  • segments – count of segments for approximation