Add an option to export a symbol's texts as DXF block attributes (#1339)

With symbols as blocks and the new "DXF : textes des symboles en
attributs" option (--dxf-attributes on the command line), a symbol's own
texts (its label, function, comment...) are attributes of its INSERT
instead of loose texts, so a CAD program moves them with the symbol and
can list or edit them. Each is written exactly where, and as, the text
was. A text showing an information field is tagged with its name
(LABEL, FUNCTION...), a typed text TEXT1, TEXT2...; a text's second line
gets _2. The block defines each tag once, placed where the first symbol
has it.

Its own option, off by default, because LibreCAD (2.2.1.5) does not
show attributes: the labels would vanish there. AutoCAD shows them.

The text geometry moves into textLines(), shared with the text loop,
so the attributes and the plain texts cannot drift apart.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ispyisail
2026-10-07 09:56:26 +13:00
parent c3ed2daca8
commit 9699b314b0
11 changed files with 266 additions and 43 deletions
+6 -3
View File
@@ -332,7 +332,7 @@ int exportImages(QETProject &project, const QString &format,
/// (DxfExport) with the dialog's default options -- the export settings of
/// the preferences -- so both give the same file.
int exportDxf(QETProject &project, const QString &out_dir, bool showTerminals,
bool dxfBlocks)
bool dxfBlocks, bool dxfAttributes)
{
const QList<Diagram *> diagrams = project.diagrams();
if (diagrams.isEmpty()) {
@@ -345,8 +345,10 @@ int exportDxf(QETProject &project, const QString &out_dir, bool showTerminals,
properties.format = QStringLiteral("DXF");
if (showTerminals)
properties.draw_terminals = true;
if (dxfBlocks)
if (dxfBlocks || dxfAttributes)
properties.dxf_blocks = true;
if (dxfAttributes)
properties.dxf_attributes = true;
int index = 0;
bool has_images = false;
@@ -986,6 +988,7 @@ int run(const QStringList &args)
QStringList filtered = args;
const bool showTerminals = filtered.removeAll("--show-terminals") > 0;
const bool dxfBlocks = filtered.removeAll("--dxf-blocks") > 0;
const bool dxfAttributes = filtered.removeAll("--dxf-attributes") > 0;
// --no-slaves and --no-junctions leave rows out of --export-bom.
const bool includeSlaves = filtered.removeAll("--no-slaves") == 0;
const bool includeJunctions = filtered.removeAll("--no-junctions") == 0;
@@ -1042,7 +1045,7 @@ int run(const QStringList &args)
if (format == "pdf")
return exportPdf(project, output, showTerminals);
if (format == "dxf")
return exportDxf(project, output, showTerminals, dxfBlocks);
return exportDxf(project, output, showTerminals, dxfBlocks, dxfAttributes);
if (format == "cables" || format == "wires")
return exportCsv(project, format, output);
if (format == "bom")