In the case of a series of trace segments, continue with a vertex from the last XY-coordinates.
While the conditions for starting or continuing are simple to determine:
if ((x1, y1) == dxf_lastX, dxf_lastY)) ...
The caveat is how to determine when to close the polyline sequence (with an ENDSEQ marker) after the last vertex (endpoint of the last trace segment).
The end cap style has to be implemented at the start and end point of a trace.
if ((dxf_x1, dxf_y1) == dxf_lastX, dxf_lastY)) ...
CIRCLE
entity has to be replaced by a POLYLINE
entity with the correct line width (trace width).
The CIRCLE
entity is to be used for (unplated) drill holes only. In the mechanical CAD program these circles (drill holes) can be extruded to the board thickness and subtracted from the extruded pcb outline.