Add an option to export symbols as DXF blocks (#1339)

With "DXF : symboles en blocs" ticked in the export dialog, or
--dxf-blocks on the command line, each symbol definition a folio uses is
written once as a DXF block and every placed symbol as an INSERT of it.
A CAD program then selects, counts and replaces a symbol as one object.

The block is drawn by the same code as a symbol drawn in full, as if
the symbol sat unturned at the folio's origin, which is DXF (0,
sheetHeight): that is the block's base point, so the INSERT carries the
symbol's position and quarter-turn and nothing else. Blocks have to come
before any entity, so the export collects them first and dxfBegin()
writes them in its BLOCKS section. Entities in a block keep their own
layers. Off by default; with it off the file is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ispyisail
2026-10-07 09:50:18 +13:00
parent 83f72c95c6
commit c3ed2daca8
12 changed files with 567 additions and 115 deletions
+10
View File
@@ -66,6 +66,7 @@ ExportProperties ExportPropertiesWidget::exportProperties() const
export_properties.draw_terminal_names = draw_terminal_names -> isChecked();
export_properties.draw_bg_transparent = draw_bg_transparent -> isChecked();
export_properties.draw_colored_conductors = draw_colored_conductors -> isChecked();
export_properties.dxf_blocks = dxf_blocks -> isChecked();
export_properties.exported_area = export_border -> isChecked() ? QET::BorderArea : QET::ElementsArea;
return(export_properties);
@@ -89,6 +90,7 @@ void ExportPropertiesWidget::setExportProperties(const ExportProperties &export_
draw_terminal_names -> setChecked(export_properties.draw_terminal_names);
draw_bg_transparent -> setChecked(export_properties.draw_bg_transparent);
draw_colored_conductors -> setChecked(export_properties.draw_colored_conductors);
dxf_blocks -> setChecked(export_properties.dxf_blocks);
if (export_properties.exported_area == QET::BorderArea) {
export_border -> setChecked(true);
@@ -219,6 +221,11 @@ void ExportPropertiesWidget::build()
// use transparent background for SVG-Export
draw_bg_transparent = new QCheckBox(tr("SVG: fond transparent"), groupbox_options);
optionshlayout -> addWidget(draw_bg_transparent, 4, 0);
// each symbol as a DXF block (issue #1339)
dxf_blocks = new QCheckBox(tr("DXF : symboles en blocs"), groupbox_options);
dxf_blocks -> setToolTip(tr("Chaque symbole devient un bloc DXF, sélectionnable d'un clic dans un logiciel de CAO"));
optionshlayout -> addWidget(dxf_blocks, 4, 1);
vboxLayout -> addWidget(groupbox_options);
@@ -234,6 +241,7 @@ void ExportPropertiesWidget::build()
setTabOrder(draw_titleblock, draw_terminals);
setTabOrder(draw_terminals, draw_colored_conductors);
setTabOrder(draw_colored_conductors, draw_bg_transparent);
setTabOrder(draw_bg_transparent, dxf_blocks);
// connexion du bouton permettant le choix du repertoire
connect(button_browse, &QPushButton::released, this, &ExportPropertiesWidget::slot_chooseADirectory);
@@ -249,6 +257,7 @@ void ExportPropertiesWidget::build()
connect(draw_terminal_names, &QCheckBox::stateChanged, this, &ExportPropertiesWidget::optionChanged);
connect(draw_bg_transparent, &QCheckBox::stateChanged, this, &ExportPropertiesWidget::optionChanged);
connect(draw_colored_conductors, &QCheckBox::stateChanged, this, &ExportPropertiesWidget::optionChanged);
connect(dxf_blocks, &QCheckBox::stateChanged, this, &ExportPropertiesWidget::optionChanged);
#else
connect(draw_grid, &QCheckBox::checkStateChanged, this, &ExportPropertiesWidget::optionChanged);
connect(draw_border, &QCheckBox::checkStateChanged, this, &ExportPropertiesWidget::optionChanged);
@@ -257,5 +266,6 @@ void ExportPropertiesWidget::build()
connect(draw_terminal_names, &QCheckBox::checkStateChanged, this, &ExportPropertiesWidget::optionChanged);
connect(draw_bg_transparent, &QCheckBox::checkStateChanged, this, &ExportPropertiesWidget::optionChanged);
connect(draw_colored_conductors, &QCheckBox::checkStateChanged, this, &ExportPropertiesWidget::optionChanged);
connect(dxf_blocks, &QCheckBox::checkStateChanged, this, &ExportPropertiesWidget::optionChanged);
#endif
}