DXF export: keep the wires' colours

Every wire was written in the default colour, whatever its colour on the
folio: 723 of the 3,190 wires in the example projects (23 %, in 10
projects) lost theirs. The wire outline now takes the wire's colour, and
its number the wire's text colour, mapped to the nearest DXF colour as
the free texts already are. Black still comes out as BYLAYER.

A two-colour wire gets its main colour, and dashed wires (46 in the
examples) stay continuous: DXF line types are not written yet.

Checked on the 24 example projects, 133 folios: exactly 723 wire
outlines now carry a colour of their own, the only change from the
previous commit; ezdxf reads all files with no audit errors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G2d2Zi8BfrYRPX88zhaoFG
This commit is contained in:
ispyisail
2026-09-27 20:51:37 +13:00
parent 1d980b164f
commit a399923575
+6 -2
View File
@@ -282,7 +282,10 @@ void DxfExport::write(Diagram *diagram, int width, int height,
poly << cond->pos()+segment->secondPoint();
}
Createdxf::layer = Layer::Wires;
Createdxf::drawPolyline(file_path,poly,0);
//The wire's own colour, as on the folio (a two-colour wire gets
//its main one). Black comes out as BYLAYER, see Createdxf.
const ConductorProperties wire_properties = cond -> properties();
Createdxf::drawPolyline(file_path, poly, Createdxf::dxfColor(wire_properties.color));
//Draw conductor text item
Createdxf::layer = Layer::WireNumbers;
ConductorTextItem *textItem = cond -> textItem();
@@ -306,7 +309,8 @@ void DxfExport::write(Diagram *diagram, int width, int height,
qreal offset = fontSize * 1.6;
foreach (QString line, lines) {
if (line.size() > 0 && line != "_" )
Createdxf::drawText(file_path, line, QPointF(x, y), fontSize, 360-angle, 0, 0.72 );
Createdxf::drawText(file_path, line, QPointF(x, y), fontSize, 360-angle,
Createdxf::dxfColor(wire_properties.text_color), 0.72 );
x += offset * xdir;
y -= offset * ydir;
}