Correct the automation docs: QET has no Python scripting and no plugins

api_reference stated "QElectroTech supports Python scripting" and
"QElectroTech supports plugins for deep integration", and told readers to
install plugins into ~/.local/share/QElectroTech/plugins/ and platform
equivalents. None of it exists: there is no QPluginLoader anywhere in
sources/, no plugin ABI, and every Python reference in the tree is the
launcher for qet_tb_generator -- a separate PyPI program QET starts as an
ordinary child process. QET never reads those plugin paths.

cli_reference had the mirror-image error, calling the shipped headless
export "Future CLI Features (QET 2.0)" and sending readers to the
scripting that does not exist. The FR/DE CLI pages additionally invented
a --dpi option and QET_PLUGIN_PATH / QET_ELEMENT_PATH, and documented an
argument order the parser cannot accept.

Rewrites api_reference (EN/FR/DE) around what is actually there: the 13
CLI verbs with their real positional syntax and exit codes, the real .qet
and .elmt XML (the old skeletons were invented -- no <diagrams> wrapper,
element has no id, uuid is an attribute), qet_tb_generator, and the C++
source. Adds a section naming what does not exist, so the claim does not
come back.

Also corrects the same claims where they had spread: features, history,
faq, user_manual (EN/FR/DE) and the sidebar.
ispyisail
2026-09-11 21:42:51 +12:00
parent 8a800dbea6
commit 4854c314f0
13 changed files with 985 additions and 1392 deletions
+1 -1
@@ -73,7 +73,7 @@
**[Contributing Code](contributing)**
**[API Reference](api_reference)** — Scripting & plugin development
**[Automating QET](api_reference)** — CLI, XML formats, external tools
**[CLI Reference](cli_reference)** — Command line usage and automation
+250 -253
@@ -1,293 +1,290 @@
# API-Referenz
# QElectroTech automatisieren
Erweitern und automatisieren Sie QElectroTech durch Scripting, Plugins und XML-Manipulation.
Wie man QET aus anderen Programmen heraus steuert, und wie die XML-Dateien
aufgebaut sind.
> **Korrektur, September 2026.** Frühere Fassungen dieser Seite behaupteten,
> QElectroTech unterstütze Python-Skripte und ein Plugin-System, und wiesen
> Leser an, Plugins nach `~/.local/share/QElectroTech/plugins/` und
> Entsprechendes zu installieren. **Nichts davon existiert.** Es gibt weder
> einen eingebetteten Interpreter noch eine Plugin-Schnittstelle noch ein
> Plugin-Verzeichnis — QET liest diese Pfade nie. Die folgende Seite beschreibt,
> was tatsächlich vorhanden ist. Das ist einiges, nur eben nicht das.
**Was QET wirklich bietet:**
| | |
|---|---|
| **Eine Kommandozeile ohne Oberfläche** | 13 Verben, die ein Projekt öffnen und exportieren, untersuchen oder neu schreiben, ohne GUI. Die eigentliche Automatisierungsfläche. |
| **XML-Dateien** | `.qet` und `.elmt` sind gewöhnliches XML, mit jedem Werkzeug les- und schreibbar. |
| **Ein externes Begleitprogramm** | `qet_tb_generator`, aus einem Menüeintrag gestartet. |
| **C++-Quellcode** | Für alle, die QET selbst oder einen Fork bauen. |
**Was es nicht bietet:** eingebettete Skripte in irgendeiner Sprache, eine
Plugin-API, ein Verzeichnis ladbarer Module oder eine
Automatisierungsschnittstelle zu einer laufenden Instanz.
---
## Überblick
## 1. Die Kommandozeile
QElectroTech bietet mehrere Möglichkeiten zur Funktionserweiterung und Workflow-Automatisierung:
1. **Scripting** — Python-Skripte zur Automatisierung
2. **Plugins** — Mit benutzerdefinierten Funktionen erweitern (Python, etc.)
3. **XML-Manipulation** — Direkte Dateienbearbeitung für benutzerdefinierte Tools
4. **Doxygen-API** — C++-API für Entwickler, die Erweiterungen erstellen
---
## Erste Schritte
### Für Wen Dieser Leitfaden
- **Entwickler** die QET erweitern möchten
- **Power-Benutzer** die Workflows automatisieren
- **Tool-Builder** die benutzerdefinierte Dienstprogramme erstellen
- **Forscher** die QET-Dateien programmatisch verarbeiten
### Voraussetzungen
- Grundlegende Programmierkenntnisse (Python empfohlen)
- Verständnis von QET-Dateiformaten (XML)
- Vertrautheit mit QET-Benutzeroberfläche und Terminologie
---
## Scripting
### Python-Scripting
QElectroTech unterstützt **Python-Scripting** für Automatisierungsaufgaben.
#### Verfügbare Anwendungsfälle
- **Leiter-Block-Generierung** — Automatisches Erstellen von Terminalleisten
- **Auto-Nummerierung** — Elemente und Leiter programmatisch nummerieren
- **Batch-Operationen** — Mehrere Diagramme verarbeiten
- **Datenexport** — Informationen aus Projekten extrahieren
- **Benutzerdefinierte Berichte** — Spezialisierte Dokumentation generieren
#### Terminal-Block-Generator (Beispiel)
Der **Terminal-Block-Generator** ist ein von der Gemeinschaft beigestütztes Python-Plugin, das die Erstellung von Terminalleisten automatisiert.
**Funktionen:**
- Generieren Sie Terminal-Blöcke aus Leiter-Listen
- Passen Sie die Terminal-Nummerierung an
- Exportieren Sie Terminal-Dokumentation
**Gemeinschaft:**
- 55 Themen, 895 Beiträge im Forum
- Aktive Entwicklung und Unterstützung
- Verfügbar auf GitHub
**Erste Schritte:**
- Forum: https://qelectrotech.org/forum/viewforum.php?id=14
- Python-Plugin-Beispiel für QET
### Ihre Eigenen Skripte Schreiben
#### Script-Struktur
QET-Skripte typischerweise:
1. **Lesen** Sie Projekt-/Element-Dateien (XML)
2. **Verarbeiten** Sie die Daten (Python-Logik)
3. **Schreiben** Sie in Datei oder generieren Sie Ausgabe
#### Beispiel-Workflow
```python
# Pseudo-Code-Beispiel
import xml.etree.ElementTree as ET
# QET-Projekt lesen
project = ET.parse('meinprojekt.qet')
root = project.getroot()
# Alle Elemente suchen
for element in root.findall('.//element'):
# Element verarbeiten
ref = element.get('id')
print(f"Verarbeite Element: {ref}")
# Zurück schreiben
project.write('meinprojekt_modifiziert.qet')
```
#### Häufige Aufgaben
**Element-Daten Lesen:**
- `.elmt` XML-Dateien analysieren
- Anschlüsse, Grafiken, Eigenschaften extrahieren
- Auf Element-Bibliotheken zugreifen
**Projekte Ändern:**
- Elemente hinzufügen/entfernen
- Leiter-Eigenschaften ändern
- Nummerierung aktualisieren
**Berichte Generieren:**
- Element-Listen extrahieren
- Nomenclature generieren
- Verdrahtungsdiagramme erstellen
### Benötigte Python-Bibliotheken
Das ist der Teil, den die meiste Automatisierung nutzen sollte. Ein erkanntes
Export-Flag wird vor dem Start der Oberfläche ausgewertet; der Prozess läuft
ohne Anzeige, erledigt die Arbeit und endet — er öffnet kein Fenster und reicht
nichts an eine bereits laufende Instanz weiter.
```bash
# XML-Verarbeitung (in Python integriert)
import xml.etree.ElementTree as ET
# Für fortgeschrittene Aufgaben
pip install lxml # Bessere XML-Unterstützung
qelectrotech --export-pdf meinprojekt.qet ausgabe.pdf
```
### Forum-Diskussion
**Argumente sind positionsgebunden, nicht `--flag=wert`.** Die Form lautet stets
`qelectrotech <flag> <projekt.qet> <ausgabe>`, mit den beiden unten genannten
Ausnahmen.
**Script-Forum:** https://qelectrotech.org/forum/viewforum.php?id=14
### Die Verben
Themen umfassen:
- Auto-Nummerungs-Skripte
- Schrank-Layout-Generatoren
- Datenextraktions-Tools
- Batch-Verarbeitungs-Beispiele
| Flag | Ausgabe | Anmerkungen |
|---|---|---|
| `--export-pdf` | ein PDF | alle Folios, je eine Seite |
| `--export-png` | ein Verzeichnis | je ein `NN_Titel.png` pro Folio |
| `--export-svg` | ein Verzeichnis | je ein `NN_Titel.svg` pro Folio |
| `--export-bom` | CSV | Stückliste, aus der Projektdatenbank — dieselbe Quelle wie der GUI-Export |
| `--export-wiring` | CSV | Von-Nach-Verdrahtungsliste, eine Zeile je Leiter |
| `--export-cables` | CSV | dieselbe logische Liste, aber aus dem Dokument-XML gebildet |
| `--export-wires` | CSV | Leiternummern |
| `--export-nets` | CSV | elektrische Netze — zu Potentialen gruppierte Klemmen |
| `--export-links` | CSV | Querverweise, mit Kennzeichnung unverknüpfter Master und Slaves |
| `--info` | JSON | struktureller Abzug: Element- und Leiterzahlen je Folio, unverbundene Klemmen. Schreibt nach **stdout**, wenn kein Pfad angegeben ist |
| `--resave` | `.qet` | lädt das Projekt und schreibt sein XML zurück |
| `--set-titleblock` | `.qet` | trägt Schriftfeldwerte ein und speichert |
| `--check-elements` | Bericht | prüft `.elmt`-Dateien — erwartet **eine Datei oder ein Verzeichnis**, kein Projekt |
Zwei zusätzliche Schalter:
- `--show-terminals` — zeichnet Klemmenmarken und -namen in PDF-/PNG-/SVG-
Ausgaben. Standardmäßig aus, passend zum Exportdialog der Oberfläche.
Nützlich, um einen unverbundenen Anschluss sichtbar zu machen.
- `--set-titleblock` nimmt nach dem Ausgabepfad Zuweisungen `schlüssel=wert`
entgegen: `date=today` oder ein ISO-Datum `JJJJ-MM-TT`, die
Standard-Schriftfeldschlüssel, oder jeden anderen Schlüssel, der als
benutzerdefiniertes Feld abgelegt wird. Fehlerhafte Zuweisungen scheitern,
bevor irgendetwas geschrieben wird.
### Rückgabewerte
`0` Erfolg · `1` die Arbeit schlug fehl (Projekt nicht zu öffnen, nichts zu
exportieren, Datei nicht beschreibbar) · `2` falsch aufgerufen (fehlendes
Argument, fehlerhafte Zuweisung). Damit lässt sich das Werkzeug direkt in einer
CI-Kette verwenden.
### Wissenswertes
- **`--export-cables` und `--export-wiring` sollen übereinstimmen.** Eines wird
aus dem Dokument-XML gebildet, das andere aus der Projektdatenbank. Beide
laufen zu lassen und zu vergleichen prüft unmittelbar, ob die Datenbank das
Projekt noch beschreibt — was sonst nur über die Oberfläche sichtbar ist.
- **Setzen Sie in Skripten immer eine Zeitgrenze.** Ein mit einer älteren
Version gespeichertes Projekt löst beim Laden eine Warnung aus; im
Kommandozeilenmodus werden Meldungsfenster automatisch beantwortet, doch ein
unerwarteter modaler Dialog ist der klassische Weg, einen Lauf ohne
Oberfläche dauerhaft hängen zu lassen.
- Absturzsicherungen sind im Kommandozeilenmodus bewusst abgeschaltet: Ihr
Schreibvorgang im Hintergrund konkurriert mit dem Prozessende.
- `QT_QPA_PLATFORM=offscreen` genügt für diese Verben. Xvfb wird nicht benötigt.
### Beispiel: eine Revisionskette
```bash
set -e
qelectrotech --set-titleblock in.qet gestempelt.qet indexrev=C date=today
qelectrotech --export-pdf gestempelt.qet "release/rev-C.pdf"
qelectrotech --export-bom gestempelt.qet "release/rev-C-bom.csv"
```
Siehe auch die **[Kommandozeilen-Referenz](cli_reference)**.
---
## Plugins
## 2. Die Dateien direkt lesen und schreiben
### Plugin-System
`.qet` und `.elmt` sind XML. Alles, was XML verarbeiten kann, kann sie
verarbeiten — Pythons `xml.etree`, `lxml`, `xmlstarlet`, XSLT, ganz wie Sie
mögen. Das ist gemeint, wenn jemand sagt, er „skripte QET“: Das Skript ist ein
eigenes Programm, das die Dateien liest und schreibt und neben QET läuft, nicht
darin.
QElectroTech unterstützt **Plugins** für tiefe Integration.
#### Verfügbare Plugins
**Terminal-Block-Generator**
- Typ: Python-Plugin
- Zweck: Automatisieren Sie die Erstellung von Terminalleisten
- Gemeinschafts-Support: Ja
- Forum: Terminal-Block-Generator-Forum (55 Themen)
#### Plugin-Entwicklung
**Erstellen Sie ein Plugin:**
1. **Verstehen Sie die Plugin-Schnittstelle** — Wie QET Ihren Code aufruft
2. **Schreiben Sie Plugin-Code** — Python oder C++ je nach Integration
3. **Verpacken Sie das Plugin** — Legen Sie es im QET-Plugin-Verzeichnis ab
4. **Testen Sie gründlich** — Gewährleisten Sie Stabilität
5. **Teilen Sie mit der Gemeinschaft** — Tragen Sie zum Forum bei
**Plugin-Verzeichnisse:**
**Linux:**
```
~/.local/share/QElectroTech/plugins/
```
**Windows:**
```
%APPDATA%\QElectroTech\plugins\
```
**macOS:**
```
~/Library/Application Support/QElectroTech/plugins/
```
#### Plugin-Beispiele
**Terminal-Block-Generator:**
- Generiert Terminal-Leisten programmatisch
- Verarbeitet Leiter-Listen
- Erstellt Nomenclature
**Mögliche Plugin-Ideen:**
- Benutzerdefinierte Element-Bibliotheks-Manager
- Report-Generatoren
- Import/Export-Übersetzer
- Design-Regel-Checker
- Materialkosten-Tools
### Forum-Diskussionen
**Code/Programmierung-Forum:** https://qelectrotech.org/forum/viewforum.php?id=17 (91 Themen, 1.231 Beiträge)
**Script-Forum:** https://qelectrotech.org/forum/viewforum.php?id=14 (33 Themen, 374 Beiträge)
---
## XML-Manipulation
### Projekt-Dateiformat (.qet)
QET-Projekte werden im XML-Format gespeichert. Grundstruktur:
### Ein echtes `.qet`-Gerüst
```xml
<?xml version="1.0" encoding="UTF-8"?>
<project>
<properties>
<author>Name</author>
<date>2026-01-01</date>
<title>Mein Projekt</title>
</properties>
<diagrams>
<diagram name="Schema 1">
<elements>
<element name="S1" type="..." x="10" y="20">
<!-- Element-Daten -->
</element>
</elements>
<conductors>
<conductor num="1">
<!-- Leiter-Daten -->
</conductor>
</conductors>
<project title="ArduinoLCD" version="0.80">
<properties>
<property show="1" name="saveddate">17/04/2021</property>
</properties>
<newdiagrams>
<border rows="8" cols="17" rowsize="80" colsize="60" .../>
<inset folio="%id/%total" author="" title="" .../>
<conductors type="multi" .../>
<report label="%f-%l%c"/>
<xrefs>
<xref type="coil" master_label="%f-%l%c" slave_label="(%f-%l%c)" .../>
</xrefs>
</newdiagrams>
<diagram title="LCD 4 DATA" order="1" folio="%id/%total" cols="11" rows="7" ...>
<elements>
<element x="390" y="570" z="10" orientation="0"
type="embed://import/oznaczenia/tekst_08.elmt"
uuid="{52d4b9e8-05c3-49a2-8455-a42ff651200a}"
prefix="" freezeLabel="false">
...
</element>
</elements>
<conductors> ... </conductors>
</diagram>
</diagrams>
<collection> ... </collection>
</project>
```
### Element-Dateiformat (.elmt)
Stolpersteine:
Benutzerdefinierte Elemente verwenden das XML-Format:
- **Es gibt keine Hülle `<diagrams>`.** `<diagram>`-Knoten sind direkte Kinder
von `<project>`, einer je Folio, geordnet über ihr Attribut `order`.
- **`<element>` hat kein `id`.** Es wird über `uuid` identifiziert, und sein
Attribut `type` ist ein *Ort*, meist `embed://…` für ein in die
projekteigene Sammlung kopiertes Element.
- **`<newdiagrams>` enthält die Vorgaben für neue Folios**, nicht die Folios
selbst.
- Die Elementdefinitionen des Projekts liegen unter `<collection>`; ein Projekt
ist daher in der Regel in sich geschlossen.
Vollständige Referenz: **[Project XML](project_XML)**.
### Ein echtes `.elmt`-Gerüst
```xml
<?xml version="1.0" encoding="UTF-8"?>
<definition version="0.100">
<uuid uuid="..."/>
<names>
<name lang="en">Mein Element</name>
<name lang="de">Mein Element</name>
</names>
<informations>...</informations>
<description>Element-Beschreibung</description>
<graphic>
<!-- Grafikelemente -->
</graphic>
<terminals>
<!-- Anschluss-Definitionen -->
</terminals>
<definition version="0.90" type="element" link_type="master"
width="200" height="70" hotspot_x="100" hotspot_y="35">
<uuid uuid="{2cbd2b72-1d04-f03d-758f-ce3a14dbb3c5}"/>
<names>
<name lang="en">UPS</name>
<name lang="fr">UPS</name>
</names>
<kindInformations>
<kindInformation name="type">coil</kindInformation>
</kindInformations>
<informations>Author: RDS for QelectroTech</informations>
<description>
<rect x="0" y="0" width="460" height="590" style="..."/>
<terminal uuid="{73279019-…}" name="" x="-90" y="10" orientation="w" type="Generic"/>
</description>
</definition>
```
### Dateien Bearbeiten
Stolpersteine:
Sie können XML-Dateien direkt ändern:
- `width`, `height`, `hotspot_x`, `hotspot_y` sind **Pflichtattribute von
`<definition>`**, und Breite/Höhe müssen Vielfache von 10 sein — sonst rundet
QET auf den nächsten Zehner auf.
- Die uuid ist ein **Attribut** (`<uuid uuid="{…}"/>`), nicht der Elementtext.
- `<name>`-Einträge gelten je Sprache und brauchen ein `lang`-Attribut.
- `link_type` macht ein Element zum Master, Slave oder zur Klemme — siehe
**[Elemente verknüpfen](element_linking)**.
1. **Extrahieren** Sie `.qet`-Datei (Umbenennung in `.zip`)
2. **Bearbeiten** Sie XML-Dateien darin
3. **Komprimieren** Sie und benennen Sie in `.qet` um
4. **Öffnen** Sie in QET
Vollständige Referenz: **[Elements XML](elements_XML)**.
### XML in Python Analysieren
### Prüfen Sie, was Sie erzeugen
```python
import xml.etree.ElementTree as ET
Eine von Hand geschriebene Datei wird erst geprüft, wenn QET sie öffnet — die
Kommandozeile prüft Elementdateien jedoch für Sie:
# Projekt laden
tree = ET.parse('meinprojekt.qet')
root = tree.getroot()
# Elemente durchlaufen
for elem in root.findall('.//element'):
name = elem.get('name')
elem_type = elem.get('type')
print(f"Element: {name}, Typ: {elem_type}")
# Änderungen speichern
tree.write('meinprojekt_modifiziert.qet', encoding='UTF-8')
```bash
qelectrotech --check-elements meine_elemente/
```
---
Jede Datei wird als OK, WARN (lädt, aber verdächtig — etwa null Klemmen) oder
FAIL (nicht lesbar, falsches Wurzel-Tag, fehlender Begrenzungsrahmen) gemeldet,
und der Rückgabewert ist bei jedem Fehlschlag ungleich null. Gehört in die CI,
wenn Sie `.elmt`-Dateien erzeugen.
## Zusätzliche Ressourcen
### Faustregeln
- **[QET Erstellen](building-DE)** — Aus Quelle kompilieren
- **[Zu QET Beitragen](contributing-DE)** — Code-Beitrag-Anleitung
- **[Doxygen-API](https://download.qelectrotech.org/qet/doxygen/html/)** — C++-API-Referenz
- **[Script-Forum](https://qelectrotech.org/forum/viewforum.php?id=14)** — Diskutieren und Teilen
- **[Code-Forum](https://qelectrotech.org/forum/viewforum.php?id=17)** — Entwickler-Fragen
- **Schließen Sie das Projekt in QET, bevor Sie seine Datei neu schreiben.** QET
hält ein eigenes Modell im Speicher und überschreibt Sie beim Speichern.
- `--resave` ist ein billiger Normalisierer: laden, zurückschreiben, dann
vergleichen — so sehen Sie, was QET stillschweigend umschreibt, bevor Sie ein
Werkzeug auf eine Annahme über das Markup stützen.
- Elemente und Leiter werden über UUID identifiziert. Einen Elementknoten zu
kopieren, ohne ihm eine neue uuid zu geben, erzeugt zwei Elemente, die QET für
dasselbe hält.
---
**[🌐 Sprache wählen](languages)** — English · Français · Deutsch
## 3. `qet_tb_generator` — was „Plugin“ bei QET bedeutet
Es gibt einen Menüeintrag, *Plugin zur Klemmenleistenerstellung starten*, und
ein Programm dahinter. `qet_tb_generator` ist ein **eigenständiges
Drittprogramm**, über PyPI verteilt, das `.qet`-Dateien von außen liest und
schreibt, um Klemmenleisten zu erzeugen.
```bash
python -m pip install --upgrade qet_tb_generator
```
QET startet es, indem es eine feste Liste von Orten durchsucht —
`QETApp::dataDir() + "/binary/"`, das aktuelle Verzeichnis, `~/.qet/` und dann,
was `PATH` auflöst — und es als gewöhnlichen Kindprozess ausführt. Das ist die
gesamte Integration: kein gemeinsamer Speicher, keine API, keine Rückrufe.
Liegt die ausführbare Datei auf keinem dieser Pfade, findet der Menüeintrag sie
nicht.
Unterstützung durch die Gemeinschaft gibt es im Forum:
[Skripte](https://qelectrotech.org/forum/viewforum.php?id=14) ·
[Code/Programmierung](https://qelectrotech.org/forum/viewforum.php?id=17)
**„Ein Plugin schreiben“ heißt daher: ein eigenständiges Programm schreiben**,
das die Dateien bearbeitet, genau wie in §2 beschrieben. Es gibt keine
Schnittstelle zu implementieren und kein Verzeichnis, in das man installiert.
---
## 4. Der C++-Quellcode
Um QET selbst zu ändern oder einen Fork zu bauen:
- **Doxygen-API-Dokumentation:**
https://de-backer.github.io/qelectrotech-source-mirror/html/pages.html
- **Quellen:** https://github.com/qelectrotech/qelectrotech-source-mirror
- **[Aus Quellcode bauen](building)** · **[Mitwirken](contributing)**
Orientierungspunkte, alle in `sources/`:
| Klasse | Datei | Rolle |
|---|---|---|
| `QETProject` | `qetproject.cpp` | ein Projekt: Folios, Sammlung, Laden und Speichern |
| `Diagram` | `diagram.cpp` | ein Folio (eine `QGraphicsScene`) |
| `Element` | `qetgraphicsitem/element.cpp` | ein platziertes Symbol |
| `Conductor` | `qetgraphicsitem/conductor.cpp` | ein Leiter |
| `Terminal` | `qetgraphicsitem/terminal.cpp` | ein Anschlusspunkt |
| `projectDataBase` | `dataBase/projectdatabase.cpp` | der Abfrage-Cache — siehe **[Die Projektdatenbank](project_database)** |
Man beachte die Wortlücke: Die Oberfläche sagt *Draht*, *Seite* und *Symbol*,
der Code sagt *conductor*, *diagram* und *element*. Nach dem Oberflächenwort zu
suchen ist der übliche Weg, fälschlich zu schließen, etwas sei nicht
implementiert.
---
## 5. Was es nicht gibt
Deutlich gesagt, weil diese Seite zuvor das Gegenteil behauptete:
| Behauptung | Wirklichkeit |
|---|---|
| Eingebettete Python-Skripte | Es ist kein Interpreter eingebunden oder geladen. Jede Python-Erwähnung im Quellcode betrifft den Starter für `qet_tb_generator`. |
| Ein Plugin-System / eine Plugin-Schnittstelle | Kein `QPluginLoader`, keine Plugin-ABI, nichts, was externen Code lädt. |
| `~/.local/share/QElectroTech/plugins/` und Entsprechungen | QET liest diese Pfade nie. Sie anzulegen bewirkt nichts. |
| Eine Automatisierungs-API zu einer laufenden Instanz | Keine. SingleApplication reicht *Dateiargumente* an eine laufende Instanz weiter, mehr nicht. |
Ob QET eine Skriptschnittstelle bekommen sollte, ist eine offene Frage — siehe
die Seiten [Vision](vision) und
[Entwicklungs-Roadmap](development_roadmap). Wenn es so weit ist, wird diese
Seite es sagen — dann, wenn es stimmt, und nicht früher.
+250 -256
@@ -1,296 +1,290 @@
# Référence API
# Automatiser QElectroTech
Étendez et automatisez QElectroTech grâce au scripting, aux plugins et à la manipulation XML.
Comment piloter QET depuis d'autres programmes, et à quoi ressemblent les
fichiers XML.
> **Correction, septembre 2026.** Les versions précédentes de cette page
> affirmaient que QElectroTech prend en charge les scripts Python et un système
> de greffons, et indiquaient aux lecteurs d'installer des greffons dans
> `~/.local/share/QElectroTech/plugins/` et équivalents. **Rien de tout cela
> n'existe.** Il n'y a ni interpréteur embarqué, ni interface de greffon, ni
> répertoire de greffons — QET ne lit jamais ces chemins. La page ci-dessous
> décrit ce qui existe réellement, et ce n'est pas rien ; ce n'est simplement
> pas cela.
**Ce que QET offre réellement :**
| | |
|---|---|
| **Une ligne de commande sans interface** | 13 verbes qui ouvrent un projet et l'exportent, l'inspectent ou le réécrivent sans interface graphique. La véritable surface d'automatisation. |
| **Des fichiers XML** | `.qet` et `.elmt` sont du XML ordinaire, lisible et modifiable par n'importe quel outil. |
| **Un programme compagnon externe** | `qet_tb_generator`, lancé depuis une entrée de menu. |
| **Le code source C++** | Pour qui construit QET lui-même, ou un fork. |
**Ce qu'il n'offre pas :** des scripts embarqués dans quelque langage que ce
soit, une API de greffons, un répertoire de modules chargeables, ou une
interface d'automatisation vers une instance en cours d'exécution.
---
## Aperçu
## 1. La ligne de commande
QElectroTech fournit plusieurs façons d'étendre les fonctionnalités et d'automatiser les workflows :
1. **Scripting** — Scripts Python pour automatisation
2. **Plugins** — Étendre avec des fonctionnalités personnalisées (Python, etc.)
3. **Manipulation XML** — Édition directe de fichiers pour outils personnalisés
4. **Doxygen API** — API C++ pour développeurs construisant des extensions
---
## Commencer
### Pour Qui Ce Guide
- **Développeurs** voulant étendre QET
- **Utilisateurs avancés** automatisant des workflows
- **Constructeurs d'outils** créant des utilitaires personnalisés
- **Chercheurs** traitant les fichiers QET programmatiquement
### Prérequis
- Connaissances de programmation de base (Python recommandé)
- Compréhension des formats de fichier QET (XML)
- Familiarité avec l'interface et la terminologie de QET
---
## Scripting
### Scripting Python
QElectroTech supporte le **scripting Python** pour les tâches d'automatisation.
#### Cas d'Utilisation Disponibles
- **Génération de blocs terminaux** — Créer automatiquement les bandes terminales
- **Auto-numérotation** — Numéroter programmatiquement les éléments et conducteurs
- **Opérations par lot** — Traiter plusieurs diagrammes
- **Export de données** — Extraire les informations des projets
- **Rapports personnalisés** — Générer une documentation spécialisée
#### Générateur de Bloc Terminal (Exemple)
Le **Générateur de Bloc Terminal** est un plugin Python contribué par la communauté qui automatise la création de bandes terminales.
**Fonctionnalités :**
- Générer des blocs terminaux à partir des listes de conducteurs
- Personnaliser la numérotation des bornes
- Exporter la documentation terminale
**Communauté :**
- 55 sujets, 895 messages au forum
- Développement et support actif
- Disponible sur GitHub
**Débuter :**
- Forum : https://qelectrotech.org/forum/viewforum.php?id=14
- Exemple de plugin Python pour QET
### Écrire Vos Propres Scripts
#### Structure des Scripts
Les scripts QET généralement :
1. **Lisent** les fichiers projet/élément (XML)
2. **Traitent** les données (logique Python)
3. **Écrivent** vers un fichier ou génèrent une sortie
#### Exemple de Workflow
```python
# Pseudo-code exemple
import xml.etree.ElementTree as ET
# Lire projet QET
project = ET.parse('monprojet.qet')
root = project.getroot()
# Trouver tous les éléments
for element in root.findall('.//element'):
# Traiter l'élément
ref = element.get('id')
print(f"Traitement l'élément : {ref}")
# Écrire
project.write('monprojet_modifie.qet')
```
#### Tâches Courantes
**Lecture des Données d'Élément :**
- Analyser les fichiers XML `.elmt`
- Extraire les bornes, graphiques, propriétés
- Accéder aux bibliothèques d'éléments
**Modification des Projets :**
- Ajouter/supprimer des éléments
- Modifier les propriétés des conducteurs
- Mettre à jour la numérotation
**Génération de Rapports :**
- Extraire les listes d'éléments
- Générer la nomenclature
- Créer des diagrammes de câblage
### Bibliothèques Python Nécessaires
C'est ce que la plupart des automatisations devraient utiliser. Un indicateur
d'export reconnu est détecté avant le démarrage de l'interface : le processus
s'exécute sans affichage, fait le travail et se termine — il n'ouvre pas de
fenêtre et ne transmet rien à une instance déjà lancée.
```bash
# Traitement XML (Python intégré)
import xml.etree.ElementTree as ET
# Pour les tâches avancées
pip install lxml # Meilleur support XML
qelectrotech --export-pdf monprojet.qet sortie.pdf
```
### Discussion du Forum
**Les arguments sont positionnels, pas `--option=valeur`.** La forme est
toujours `qelectrotech <indicateur> <projet.qet> <sortie>`, avec les deux
exceptions signalées plus bas.
**Forum des Scripts :** https://qelectrotech.org/forum/viewforum.php?id=14
### Les verbes
Les sujets incluent :
- Scripts d'auto-numérotation
- Générateurs de mise en page armoire
- Outils d'extraction de données
- Exemples de traitement par lot
| Indicateur | Sortie | Remarques |
|---|---|---|
| `--export-pdf` | un PDF | tous les folios, une page chacun |
| `--export-png` | un répertoire | un `NN_Titre.png` par folio |
| `--export-svg` | un répertoire | un `NN_Titre.svg` par folio |
| `--export-bom` | CSV | nomenclature, depuis la base de données du projet — la même source que l'export de l'interface |
| `--export-wiring` | CSV | liste de câblage de-à, une ligne par conducteur |
| `--export-cables` | CSV | la même liste logique, construite depuis le XML du document |
| `--export-wires` | CSV | numéros de conducteurs |
| `--export-nets` | CSV | réseaux électriques — bornes groupées en potentiels |
| `--export-links` | CSV | renvois de folio, signalant maîtres et esclaves sans lien |
| `--info` | JSON | relevé structurel : comptes d'éléments et de conducteurs par folio, bornes non connectées. Écrit sur **stdout** si aucun chemin n'est donné |
| `--resave` | `.qet` | charge le projet et réécrit son XML |
| `--set-titleblock` | `.qet` | renseigne des champs de cartouche, puis enregistre |
| `--check-elements` | rapport | valide des fichiers `.elmt` — prend **un fichier ou un répertoire**, pas un projet |
Deux commutateurs supplémentaires :
- `--show-terminals` — dessine les marqueurs et noms de bornes dans les sorties
PDF/PNG/SVG. Désactivé par défaut, conformément au dialogue d'export de
l'interface. Utile pour repérer visuellement une broche non connectée.
- `--set-titleblock` accepte des affectations `clé=valeur` après le chemin de
sortie : `date=today` ou une date ISO `AAAA-MM-JJ`, les clés standard de
cartouche, ou toute autre clé, enregistrée comme champ personnalisé. Une
affectation incorrecte échoue avant toute écriture.
### Codes de retour
`0` succès · `1` le travail a échoué (projet illisible, rien à exporter,
fichier non inscriptible) · `2` erreur d'appel (argument manquant, affectation
incorrecte). Cela rend l'outil directement utilisable dans une chaîne
d'intégration continue.
### Bon à savoir
- **`--export-cables` et `--export-wiring` doivent concorder.** L'un est
construit depuis le XML du document, l'autre depuis la base de données du
projet. Lancer les deux et les comparer vérifie directement que la base
décrit toujours le projet — ce qui n'est autrement observable que via
l'interface.
- **Prévoyez toujours un délai d'expiration dans vos scripts.** Un projet
enregistré par une version antérieure déclenche un avertissement au
chargement ; en mode ligne de commande les boîtes de dialogue sont répondues
automatiquement, mais une fenêtre modale imprévue reste la façon classique de
bloquer indéfiniment une exécution sans interface.
- Les sauvegardes de récupération après plantage sont volontairement désactivées
en mode ligne de commande : leur écriture en arrière-plan entre en
concurrence avec la fin du processus.
- `QT_QPA_PLATFORM=offscreen` suffit pour ces verbes. Xvfb n'est pas nécessaire.
### Exemple : une chaîne de révision
```bash
set -e
qelectrotech --set-titleblock in.qet estampille.qet indexrev=C date=today
qelectrotech --export-pdf estampille.qet "release/rev-C.pdf"
qelectrotech --export-bom estampille.qet "release/rev-C-bom.csv"
```
Voir aussi la **[Référence ligne de commande](cli_reference)**.
---
## Plugins
## 2. Lire et écrire les fichiers directement
### Système de Plugins
`.qet` et `.elmt` sont du XML. Tout ce qui sait analyser du XML peut les
traiter — `xml.etree` de Python, `lxml`, `xmlstarlet`, XSLT, à votre
convenance. C'est ce que les gens veulent dire lorsqu'ils parlent de « scripter
QET » : le script est un programme à vous, qui lit et écrit les fichiers, et
qui s'exécute à côté de QET, non à l'intérieur.
QElectroTech supporte les **plugins** pour une intégration profonde.
#### Plugins Disponibles
**Générateur de Bloc Terminal**
- Type : Plugin Python
- Objectif : Automatiser la création de bandes terminales
- Support communautaire : Oui
- Forum : Forum du générateur de bloc terminal (55 sujets)
#### Développement de Plugin
**Créer un Plugin :**
1. **Comprendre l'interface du plugin** — Comment QET appelle votre code
2. **Écrire le code du plugin** — Python ou C++ en fonction de l'intégration
3. **Empaqueter le plugin** — Placer dans le répertoire des plugins QET
4. **Tester complètement** — Assurer la stabilité
5. **Partager avec la communauté** — Contribuer au forum
**Répertoires de Plugin :**
**Linux :**
```
~/.local/share/QElectroTech/plugins/
```
**Windows :**
```
%APPDATA%\QElectroTech\plugins\
```
**macOS :**
```
~/Library/Application Support/QElectroTech/plugins/
```
#### Exemples de Plugin
**Générateur de Bloc Terminal :**
- Génère les bandes terminales programmatiquement
- Traite les listes de conducteurs
- Crée la nomenclature
**Idées de Plugin Potentielles :**
- Gestionnaires de bibliothèque d'éléments personnalisés
- Générateurs de rapports
- Traducteurs import/export
- Vérificateurs de règles de conception
- Outils de nomenclature
### Discussions du Forum
**Forum Code/Programmation :** https://qelectrotech.org/forum/viewforum.php?id=17 (91 sujets, 1.231 messages)
**Forum Scripts :** https://qelectrotech.org/forum/viewforum.php?id=14 (33 sujets, 374 messages)
---
## Manipulation XML
### Format de Fichier Projet (.qet)
Les projets QET sont stockés au format XML. Structure de base :
### Un vrai squelette `.qet`
```xml
<?xml version="1.0" encoding="UTF-8"?>
<project>
<properties>
<author>Nom</author>
<date>2026-01-01</date>
<title>Mon Projet</title>
</properties>
<diagrams>
<diagram name="Schema 1">
<elements>
<element name="S1" type="..." x="10" y="20">
<!-- données d'élément -->
</element>
</elements>
<conductors>
<conductor num="1">
<!-- données de conducteur -->
</conductor>
</conductors>
<project title="ArduinoLCD" version="0.80">
<properties>
<property show="1" name="saveddate">17/04/2021</property>
</properties>
<newdiagrams>
<border rows="8" cols="17" rowsize="80" colsize="60" .../>
<inset folio="%id/%total" author="" title="" .../>
<conductors type="multi" .../>
<report label="%f-%l%c"/>
<xrefs>
<xref type="coil" master_label="%f-%l%c" slave_label="(%f-%l%c)" .../>
</xrefs>
</newdiagrams>
<diagram title="LCD 4 DATA" order="1" folio="%id/%total" cols="11" rows="7" ...>
<elements>
<element x="390" y="570" z="10" orientation="0"
type="embed://import/oznaczenia/tekst_08.elmt"
uuid="{52d4b9e8-05c3-49a2-8455-a42ff651200a}"
prefix="" freezeLabel="false">
...
</element>
</elements>
<conductors> ... </conductors>
</diagram>
</diagrams>
<collection> ... </collection>
</project>
```
### Format de Fichier Élément (.elmt)
Les points qui font trébucher :
Les éléments personnalisés utilisent le format XML :
- **Il n'y a pas d'enveloppe `<diagrams>`.** Les `<diagram>` sont des enfants
directs de `<project>`, un par folio, ordonnés par leur attribut `order`.
- **`<element>` n'a pas d'`id`.** Il est identifié par `uuid`, et son attribut
`type` est un *emplacement*, généralement `embed://…` pour un élément copié
dans la collection propre au projet.
- **`<newdiagrams>` contient les valeurs par défaut des nouveaux folios**, pas
les folios eux-mêmes.
- Les définitions d'éléments du projet vivent sous `<collection>` : un projet
est donc généralement autonome.
Référence complète : **[Project XML](project_XML)**.
### Un vrai squelette `.elmt`
```xml
<?xml version="1.0" encoding="UTF-8"?>
<definition version="0.100">
<uuid uuid="..."/>
<names>
<name lang="en">Mon Élément</name>
<name lang="fr">Mon Élément</name>
</names>
<informations>...</informations>
<description>Description de l'élément</description>
<kindInformations>
<kindInformation name="type">switch</kindInformation>
</kindInformations>
<graphic>
<!-- Éléments graphiques -->
</graphic>
<terminals>
<!-- Définitions de bornes -->
</terminals>
<definition version="0.90" type="element" link_type="master"
width="200" height="70" hotspot_x="100" hotspot_y="35">
<uuid uuid="{2cbd2b72-1d04-f03d-758f-ce3a14dbb3c5}"/>
<names>
<name lang="en">UPS</name>
<name lang="fr">UPS</name>
</names>
<kindInformations>
<kindInformation name="type">coil</kindInformation>
</kindInformations>
<informations>Author: RDS for QelectroTech</informations>
<description>
<rect x="0" y="0" width="460" height="590" style="..."/>
<terminal uuid="{73279019-…}" name="" x="-90" y="10" orientation="w" type="Generic"/>
</description>
</definition>
```
### Édition de Fichiers
Les points qui font trébucher :
Vous pouvez directement modifier les fichiers XML :
- `width`, `height`, `hotspot_x`, `hotspot_y` sont des **attributs obligatoires
de `<definition>`**, et largeur/hauteur doivent être des multiples de 10 —
sans quoi QET arrondit à la dizaine supérieure.
- L'uuid est un **attribut** (`<uuid uuid="{…}"/>`), pas le texte de l'élément.
- Les `<name>` sont par langue et exigent un attribut `lang`.
- `link_type` est ce qui fait d'un élément un maître, un esclave ou un bornier —
voir **[Lier des éléments](element_linking)**.
1. **Extraire** le fichier `.qet` (renommer en `.zip`)
2. **Éditer** les fichiers XML à l'intérieur
3. **Compresser** et renommer en `.qet`
4. **Ouvrir** dans QET
Référence complète : **[Elements XML](elements_XML)**.
### Parsing XML en Python
### Validez ce que vous produisez
```python
import xml.etree.ElementTree as ET
Rien ne contrôle un fichier écrit à la main avant que QET ne l'ouvre, mais la
ligne de commande vérifie les fichiers d'éléments pour vous :
# Charger projet
tree = ET.parse('myproject.qet')
root = tree.getroot()
# Parcourir les éléments
for elem in root.findall('.//element'):
name = elem.get('name')
elem_type = elem.get('type')
print(f"Élément : {name}, Type : {elem_type}")
# Sauvegarder les modifications
tree.write('myproject_modified.qet', encoding='UTF-8')
```bash
qelectrotech --check-elements mes_elements/
```
---
Chaque fichier est signalé OK, WARN (se charge mais suspect — par exemple zéro
borne) ou FAIL (illisible, racine incorrecte, boîte englobante manquante), et
le code de retour est non nul en cas d'échec. À mettre en intégration continue
si vous générez des `.elmt`.
## Ressources Supplémentaires
### Règles empiriques
- **[Construire QET](building-FR)** — Compiler à partir de la source
- **[Contribuer à QET](contributing-FR)** — Guide de contribution de code
- **[API Doxygen](https://download.qelectrotech.org/qet/doxygen/html/)** — Référence API C++
- **[Forum Scripts](https://qelectrotech.org/forum/viewforum.php?id=14)** — Discuter et partager
- **[Forum Code](https://qelectrotech.org/forum/viewforum.php?id=17)** — Questions de développement
- **Fermez le projet dans QET avant de réécrire son fichier.** QET détient son
propre modèle en mémoire et vous écrasera à l'enregistrement.
- `--resave` est un normaliseur bon marché : chargez, réécrivez, puis comparez,
pour voir ce que QET réécrit silencieusement avant de fonder un outil sur une
hypothèse de balisage.
- L'identité des éléments et des conducteurs passe par l'UUID. Copier un nœud
d'élément sans lui donner un nouvel uuid produit deux éléments que QET
considère comme un seul.
---
**[🌐 Choisir la Langue](languages)** — English · Français · Deutsch
## 3. `qet_tb_generator` — ce que « greffon » veut dire dans QET
Il existe une entrée de menu, *Lancer le plugin de création de borniers*, et un
programme derrière elle. `qet_tb_generator` est un **programme tiers distinct**,
distribué sur PyPI, qui lit et écrit des fichiers `.qet` depuis l'extérieur
pour construire des borniers.
```bash
python -m pip install --upgrade qet_tb_generator
```
QET le lance en parcourant une liste fixe d'emplacements — `QETApp::dataDir() +
"/binary/"`, le répertoire courant, `~/.qet/`, puis ce que résout le `PATH` — et
en le démarrant comme un processus fils ordinaire. C'est là toute
l'intégration : pas de mémoire partagée, pas d'API, pas de rappels. Si
l'exécutable ne se trouve sur aucun de ces chemins, l'entrée de menu ne peut
pas le trouver.
Le support communautaire se trouve sur le forum :
[Scripts](https://qelectrotech.org/forum/viewforum.php?id=14) ·
[Code/Programmation](https://qelectrotech.org/forum/viewforum.php?id=17)
**Écrire « un greffon » revient donc à écrire un programme autonome** qui
manipule les fichiers, exactement comme au §2. Il n'y a aucune interface à
implémenter ni aucun répertoire où s'installer.
---
## 4. Le code source C++
Pour modifier QET lui-même, ou construire un fork :
- **Documentation Doxygen de l'API :**
https://de-backer.github.io/qelectrotech-source-mirror/html/pages.html
- **Sources :** https://github.com/qelectrotech/qelectrotech-source-mirror
- **[Construire depuis les sources](building)** · **[Contribuer](contributing)**
Repères, tous dans `sources/` :
| Classe | Fichier | Rôle |
|---|---|---|
| `QETProject` | `qetproject.cpp` | un projet : folios, collection, chargement et enregistrement |
| `Diagram` | `diagram.cpp` | un folio (une `QGraphicsScene`) |
| `Element` | `qetgraphicsitem/element.cpp` | un symbole placé |
| `Conductor` | `qetgraphicsitem/conductor.cpp` | un conducteur |
| `Terminal` | `qetgraphicsitem/terminal.cpp` | un point de connexion |
| `projectDataBase` | `dataBase/projectdatabase.cpp` | le cache de requêtes — voir **[La base de données du projet](project_database)** |
Attention à l'écart de vocabulaire : l'interface dit *fil*, *page* et *symbole* ;
le code dit *conductor*, *diagram* et *element*. Chercher le mot de l'interface
est la façon habituelle de conclure à tort qu'une chose n'est pas implémentée.
---
## 5. Ce qui n'existe pas
Dit clairement, puisque cette page affirmait le contraire :
| Affirmation | Réalité |
|---|---|
| Scripts Python embarqués | Aucun interpréteur n'est lié ni chargé. Toute mention de Python dans le code est le lanceur de `qet_tb_generator`. |
| Un système / une interface de greffons | Aucun `QPluginLoader`, aucune ABI de greffon, rien qui charge du code externe. |
| `~/.local/share/QElectroTech/plugins/` et équivalents | QET ne lit jamais ces chemins. Les créer ne fait rien. |
| Une API d'automatisation vers une instance en cours | Aucune. SingleApplication transmet des *arguments de fichiers* à une instance lancée, c'est tout. |
Savoir si QET doit se doter d'une interface de script est une question ouverte —
voir les pages [Vision](vision) et [Feuille de route](development_roadmap). Si
cela arrive, cette page le dira quand ce sera réel, et pas avant.
+231 -549
@@ -1,599 +1,281 @@
# API Reference
# Automating QElectroTech
Extend and automate QElectroTech through scripting, plugins, and XML manipulation.
How to drive QET from other programs, and what the XML files look like.
> **Correction, September 2026.** Earlier versions of this page stated that
> QElectroTech supports Python scripting and a plugin system, and told readers
> to install plugins into `~/.local/share/QElectroTech/plugins/` and
> equivalents. **None of that exists.** There is no embedded interpreter, no
> plugin interface, and no plugin directory — QET never reads those paths. The
> page below describes what is actually there, which is a good deal, just not
> that.
**What QET actually offers:**
| | |
|---|---|
| **A headless command line** | 13 verbs that open a project and export, inspect or rewrite it without a GUI. The real automation surface. |
| **XML files** | `.qet` and `.elmt` are plain XML you can read and write with any tool. |
| **An external companion program** | `qet_tb_generator`, launched from a menu entry. |
| **C++ source** | For anyone building QET itself, or a fork. |
**What it does not offer:** embedded scripting of any language, a plugin API, a
loadable-module directory, or an IPC/automation interface into a running
instance.
---
## Overview
## 1. The command line
QElectroTech provides multiple ways to extend functionality and automate workflows:
1. **Scripting** — Python scripts for automation
2. **Plugins** — Extend with custom functionality (Python, etc.)
3. **XML Manipulation** — Direct file editing for custom tools
4. **Doxygen API** — C++ API for developers building extensions
---
## Getting Started
### Who This Guide Is For
- **Developers** wanting to extend QET
- **Power users** automating workflows
- **Tool builders** creating custom utilities
- **Researchers** processing QET files programmatically
### Prerequisites
- Basic programming knowledge (Python recommended)
- Understanding of QET file formats (XML)
- Familiarity with QET's UI and terminology
---
## Scripting
### Python Scripting
QElectroTech supports **Python scripting** for automation tasks.
#### Available Use Cases
- **Terminal block generation** — Automatically create terminal strips
- **Auto-numbering** — Programmatically number elements and conductors
- **Batch operations** — Process multiple diagrams
- **Data export** — Extract information from projects
- **Custom reports** — Generate specialized documentation
#### Terminal Block Generator (Example)
The **Terminal Block Generator** is a community-contributed Python plugin that automates terminal strip creation.
**Features:**
- Generate terminal blocks from conductor lists
- Customize terminal numbering
- Export terminal documentation
**Community:**
- 55 topics, 895 posts in forum
- Active development and support
- Available on GitHub
**Getting Started:**
- Forum: https://qelectrotech.org/forum/viewforum.php?id=14
- Python plugin example for QET
### Writing Your Own Scripts
#### Script Structure
QET scripts typically:
1. **Read** project/element files (XML)
2. **Process** the data (Python logic)
3. **Write** back to file or generate output
#### Example Workflow
```python
# Pseudo-code example
import xml.etree.ElementTree as ET
# Read QET project
project = ET.parse('myproject.qet')
root = project.getroot()
# Find all elements
for element in root.findall('.//element'):
# Process element
ref = element.get('id')
print(f"Processing element: {ref}")
# Write back
project.write('myproject_modified.qet')
```
#### Common Tasks
**Reading Element Data:**
- Parse `.elmt` XML files
- Extract terminals, graphics, properties
- Access element libraries
**Modifying Projects:**
- Add/remove elements
- Change conductor properties
- Update numbering
**Generating Reports:**
- Extract element lists
- Generate nomenclature
- Create wiring diagrams
### Python Libraries Needed
This is the part most automation should use. A recognised export flag is
detected before the GUI starts, so the process runs headless, does the work and
exits — it does not open a window and does not hand off to an already-running
instance.
```bash
# XML processing (built-in Python)
import xml.etree.ElementTree as ET
# For advanced tasks
pip install lxml # Better XML support
qelectrotech --export-pdf myproject.qet out.pdf
```
### Forum Discussion
**Arguments are positional, not `--flag=value`.** The shape is always
`qelectrotech <flag> <project.qet> <output>`, with two exceptions noted below.
**Scripts Forum:** https://qelectrotech.org/forum/viewforum.php?id=14
### The verbs
Topics include:
- Auto-numbering scripts
- Cabinet layout generators
- Data extraction tools
- Batch processing examples
| Flag | Output | Notes |
|---|---|---|
| `--export-pdf` | one PDF | all folios, one page each |
| `--export-png` | a directory | one `NN_Title.png` per folio |
| `--export-svg` | a directory | one `NN_Title.svg` per folio |
| `--export-bom` | CSV | bill of materials, from the project database — same source as the GUI export |
| `--export-wiring` | CSV | from-to wiring list, one row per conductor |
| `--export-cables` | CSV | the same logical list, built from the document XML instead |
| `--export-wires` | CSV | conductor numbers |
| `--export-nets` | CSV | electrical nets — terminals grouped into potentials |
| `--export-links` | CSV | cross-references, flagging masters and slaves with no link |
| `--info` | JSON | structural dump: per-folio element and conductor counts, unconnected terminals. Writes to **stdout** if no output path is given |
| `--resave` | `.qet` | loads and writes the XML back out |
| `--set-titleblock` | `.qet` | stamps title-block fields, then saves |
| `--check-elements` | report | validates `.elmt` files — takes **a file or directory**, not a project |
Two extra switches:
- `--show-terminals` — paint terminal markers and names into PDF/PNG/SVG
output. Off by default, which matches the GUI export dialog. Useful for
visually debugging an unconnected pin.
- `--set-titleblock` takes trailing `key=value` assignments after the output
path: `date=today` or an ISO `YYYY-MM-DD` date, standard title-block keys, or
any other key, which is stored as a custom field. Bad assignments fail before
anything is written.
### Exit codes
`0` success · `1` the work failed (project would not open, nothing to export,
file not writable) · `2` you called it wrong (missing argument, bad assignment).
That makes it safe to use in a CI pipeline directly.
### Worth knowing
- **`--export-cables` and `--export-wiring` are meant to agree.** One is built
from the document XML, the other from the project database. Running both and
diffing them is a direct check that the database still describes the project
— something otherwise only observable through the GUI.
- **Always pass a timeout in scripts.** A project saved by an older QET raises a
version warning on load; CLI mode answers message boxes instead of showing
them, but an unexpected modal is the classic way to hang a headless run
forever.
- Crash-recovery backups are disabled in CLI mode on purpose — the background
backup write races process exit.
- `QT_QPA_PLATFORM=offscreen` is enough for these verbs. No Xvfb is required.
### Example: a revision pipeline
```bash
set -e
qelectrotech --set-titleblock in.qet stamped.qet indexrev=C date=today
qelectrotech --export-pdf stamped.qet "release/rev-C.pdf"
qelectrotech --export-bom stamped.qet "release/rev-C-bom.csv"
```
See also the **[CLI Reference](cli_reference)**.
---
## Plugins
## 2. Reading and writing the files directly
### Plugin System
`.qet` and `.elmt` are XML. Anything that can parse XML can process them —
Python's `xml.etree`, `lxml`, `xmlstarlet`, XSLT, whatever you like. This is
what people mean when they say they "script QET": the script is an ordinary
program of your own that reads and writes the files, run alongside QET rather
than inside it.
QElectroTech supports **plugins** for deep integration.
### A real `.qet` skeleton
#### Available Plugins
**Terminal Block Generator**
- Type: Python plugin
- Purpose: Automate terminal strip creation
- Community support: Yes
- Forum: Terminal block generator forum (55 topics)
#### Plugin Development
**Creating a Plugin:**
1. **Understand the plugin interface** — How QET calls your code
2. **Write plugin code** — Python or C++ depending on integration
3. **Package the plugin** — Place in QET plugins directory
4. **Test thoroughly** — Ensure stability
5. **Share with community** — Contribute to forum
**Plugin Directories:**
**Linux:**
```
~/.local/share/QElectroTech/plugins/
```
**Windows:**
```
%APPDATA%\QElectroTech\plugins\
```
**macOS:**
```
~/Library/Application Support/QElectroTech/plugins/
```
#### Plugin Examples
**Terminal Block Generator:**
- Generates terminal strips programmatically
- Processes conductor lists
- Creates nomenclature
**Potential Plugin Ideas:**
- Custom element library managers
- Report generators
- Import/export translators
- Design rule checkers
- Bill of materials tools
### Forum Discussions
**Code/Programming Forum:** https://qelectrotech.org/forum/viewforum.php?id=17 (91 topics, 1,231 posts)
**Scripts Forum:** https://qelectrotech.org/forum/viewforum.php?id=14 (33 topics, 374 posts)
---
## XML Manipulation
### File Formats
QElectroTech uses **XML-based formats** for extensibility:
#### Project Files (.qet)
Structure:
```xml
<?xml version="1.0" encoding="UTF-8"?>
<project>
<properties>
<!-- Project metadata -->
</properties>
<diagrams>
<diagram>
<elements>
<element id="..." type="..." x="..." y="...">
<!-- Element properties -->
</element>
</elements>
<conductors>
<!-- Wire/conductor definitions -->
</conductors>
<project title="ArduinoLCD" version="0.80">
<properties>
<property show="1" name="saveddate">17/04/2021</property>
</properties>
<newdiagrams>
<border rows="8" cols="17" rowsize="80" colsize="60" .../>
<inset folio="%id/%total" author="" title="" .../>
<conductors type="multi" .../>
<report label="%f-%l%c"/>
<xrefs>
<xref type="coil" master_label="%f-%l%c" slave_label="(%f-%l%c)" .../>
</xrefs>
</newdiagrams>
<diagram title="LCD 4 DATA" order="1" folio="%id/%total" cols="11" rows="7" ...>
<elements>
<element x="390" y="570" z="10" orientation="0"
type="embed://import/oznaczenia/tekst_08.elmt"
uuid="{52d4b9e8-05c3-49a2-8455-a42ff651200a}"
prefix="" freezeLabel="false">
...
</element>
</elements>
<conductors> ... </conductors>
</diagram>
</diagrams>
<collection> ... </collection>
</project>
```
See: **[Project XML Structure](project_XML)**
Points that trip people up:
#### Element Files (.elmt)
- **There is no `<diagrams>` wrapper.** `<diagram>` elements are direct
children of `<project>`, one per folio, ordered by their `order` attribute.
- **`<element>` has no `id`.** It is identified by `uuid`, and its `type`
attribute is a *location*, usually `embed://…` for an element copied into the
project's own collection.
- **`<newdiagrams>` holds the defaults for new folios**, not the folios
themselves.
- Project-wide element definitions live under `<collection>`, so a project is
usually self-contained.
Full reference: **[Project XML](project_XML)**.
### A real `.elmt` skeleton
Structure:
```xml
<?xml version="1.0" encoding="UTF-8"?>
<definition>
<uuid>...</uuid>
<names>
<name>...</name>
</names>
<description>
<!-- Graphics -->
</description>
<!-- Terminals, information -->
<definition version="0.90" type="element" link_type="master"
width="200" height="70" hotspot_x="100" hotspot_y="35">
<uuid uuid="{2cbd2b72-1d04-f03d-758f-ce3a14dbb3c5}"/>
<names>
<name lang="en">UPS</name>
<name lang="fr">UPS</name>
</names>
<kindInformations>
<kindInformation name="type">coil</kindInformation>
</kindInformations>
<informations>Author: RDS for QElectroTech</informations>
<description>
<rect x="0" y="0" width="460" height="590" style="..."/>
<terminal uuid="{73279019-…}" name="" x="-90" y="10" orientation="w" type="Generic"/>
</description>
</definition>
```
See: **[Elements XML Structure](elements_XML)**
Points that trip people up:
### Direct XML Processing
- `width`, `height`, `hotspot_x`, `hotspot_y` are **required attributes of
`<definition>`**, and width/height must be multiples of 10 — QET rounds them
up otherwise.
- The uuid is an **attribute** (`<uuid uuid="{…}"/>`), not element text.
- `<name>` entries are per-language and need a `lang` attribute.
- `link_type` is what makes an element a master, slave or terminal — see
**[Linking elements](element_linking)**.
You can manipulate `.qet` and `.elmt` files directly:
Full reference: **[Elements XML](elements_XML)**.
**Reading:** Parse XML, extract data
**Modifying:** Change XML elements, save
**Creating:** Build XML from scratch
### Validate what you generate
**Python Example:**
```python
import xml.etree.ElementTree as ET
# Read element file
tree = ET.parse('my_element.elmt')
root = tree.getroot()
# Find terminals
for terminal in root.findall('.//terminal'):
x = terminal.get('x')
y = terminal.get('y')
print(f"Terminal at ({x}, {y})")
# Save modified file
tree.write('my_element_modified.elmt')
```
### Advantages
✅ Direct control over file contents
✅ No API limitations
✅ Work offline
✅ Version control friendly
✅ Tool-agnostic
### Limitations
⚠️ Must understand XML schema
⚠️ No validation (can create invalid files)
⚠️ Must close QET before modifying
⚠️ Manual property handling
---
## C++ API
### Doxygen Documentation
For C++ developers building QET extensions or forks:
**[QElectroTech Doxygen API Docs](https://de-backer.github.io/qelectrotech-source-mirror/html/pages.html)**
Includes:
- Class definitions and hierarchies
- Method signatures
- Property documentation
- Architecture overview
- Internal data structures
### Architecture Overview
**[QET Architecture Guide](https://de-backer.github.io/qelectrotech-source-mirror/html/pages.html)**
Key components:
- **QetDiagramEditor** — Main diagram editing class
- **Element** — Represents diagram elements
- **Conductor** — Electrical connections
- **Project** — Manages diagrams
- **ElementsLocation** — Element collection management
### Building Extensions
**For C++ developers:**
1. **[Build QET from source](building)** — Get development environment
2. **Study architecture** — Understand class hierarchy
3. **Write extension** — Subclass or integrate
4. **Test thoroughly** — Verify functionality
5. **[Contribute](contributing)** — Consider merging upstream
### Development Resources
- **Source code:** https://github.com/qelectrotech/qelectrotech-source-mirror
- **Build guide:** **[Building QET](building)**
- **Contributing:** **[How to Contribute](contributing)**
- **API docs:** Doxygen (above)
---
## Common API Tasks
### Task: Extract All Element Data
**Goal:** List all elements in a project with properties
**Approach:** Parse `.qet` XML
```python
import xml.etree.ElementTree as ET
def extract_elements(qet_file):
tree = ET.parse(qet_file)
root = tree.getroot()
elements = []
for elem in root.findall('.//element'):
elements.append({
'id': elem.get('id'),
'type': elem.get('type'),
'x': elem.get('x'),
'y': elem.get('y'),
})
return elements
# Usage
all_elements = extract_elements('myproject.qet')
for elem in all_elements:
print(f"{elem['id']}: {elem['type']}")
```
### Task: Generate Bill of Materials
**Goal:** Create parts list from project
**Approach:**
1. Extract all elements
2. Count by type
3. Export to CSV
### Task: Auto-Number Elements
**Goal:** Automatically assign reference designators (S1, R1, etc.)
**Approach:**
1. Parse project
2. Identify element types
3. Assign sequential numbers
4. Write back to file
### Task: Batch Convert Projects
**Goal:** Process multiple `.qet` files
**Approach:**
1. Find all `.qet` files
2. Process each
3. Write output (PDF, CSV, etc.)
### Task: Create Custom Elements Programmatically
**Goal:** Generate element files from data
**Approach:**
1. Build XML structure
2. Define graphics/terminals
3. Write `.elmt` file
4. Import into QET
---
## Best Practices
### Script Development
**Do:**
- Start with small test projects
- Test thoroughly before production use
- Version control your scripts
- Document what your script does
- Handle errors gracefully
- Back up project files before modifications
⚠️ **Don't:**
- Modify projects while QET is open
- Assume file format stability
- Skip error handling
- Distribute without testing
- Ignore XML schema
- Forget to commit/backup
### Performance
**For large projects:**
- Use streaming XML parsing if available
- Process incrementally
- Monitor memory usage
- Test with realistic data sizes
### Compatibility
**File format changes:**
- QET evolves; XML schema may change
- Test scripts with multiple QET versions
- Document version requirements
- Plan for migrations
---
## Community Resources
### Forums
**[Scripts Forum](https://qelectrotech.org/forum/viewforum.php?id=14)**
- 33 topics, 374 posts
- Share scripts and examples
- Get help with automation
**[Code/Programming Forum](https://qelectrotech.org/forum/viewforum.php?id=17)**
- 91 topics, 1,231 posts
- Discuss implementation
- Ask technical questions
**[Terminal Block Generator](https://qelectrotech.org/forum/viewforum.php?id=?)** (if available)
- Python plugin discussions
- Terminal automation examples
### Documentation
- **[Project XML Structure](project_XML)** — `.qet` file format
- **[Elements XML Structure](elements_XML)** — `.elmt` file format
- **[Doxygen API Docs](https://de-backer.github.io/qelectrotech-source-mirror/html/pages.html)** — C++ reference
- **[Building QET](building)** — Development setup
- **[Contributing](contributing)** — Upstream contribution
### Repositories
- **[Main Repository](https://github.com/qelectrotech/qelectrotech-source-mirror)** — Source code
- **[Elements Repository](https://github.com/qelectrotech/qelectrotech-elements)** — Element libraries
---
## Getting Help
### Troubleshooting Scripts
1. **Check XML validity** — Use XML validator
2. **Test with sample file** — Start small
3. **Read error messages** — They're usually helpful
4. **Print debug info** — Add logging
5. **Ask on forum** — Share code and error
### Asking for Help
When posting on forums:
1. Describe what you're trying to do
2. Share relevant code (in code blocks)
3. Show error messages/output
4. Mention QET version
5. Attach small test file (if relevant)
### Example Forum Post
> **Title:** "Script to extract conductor properties"
>
> **Body:** I'm writing a Python script to extract all conductor information from my QET project and export to CSV. I'm getting an XML parsing error. Here's my code: [code block]
>
> **Error message:** [error output]
>
> QET version: 0.100
>
> Any help appreciated!
---
## Future API Development
### Planned Improvements
QET 2.0 refactoring will include:
- Better scripting support
- Plugin system improvements
- Database-backed access (SQLite)
- Programmatic file generation
See: **[Development Roadmap](development_roadmap)**
### Contributing to API
Have API requests or ideas?
- **[GitHub Discussions](https://github.com/qelectrotech/qelectrotech-source-mirror/discussions)** — Suggest features
- **[Forum](https://qelectrotech.org/forum/)** — Discuss ideas
- **[Contribute code](contributing)** — Implement improvements
---
## Quick Start
### 1. Simple Python Script
```python
# Extract elements from project
import xml.etree.ElementTree as ET
project = ET.parse('myproject.qet')
for elem in project.findall('.//element'):
print(elem.get('id'))
```
### 2. Explore XML Files
Nothing checks a hand-written file until QET opens it, but the CLI will check
element files for you:
```bash
# Extract and view project structure
unzip -c myproject.qet | head -50
qelectrotech --check-elements my_elements/
```
### 3. Use Existing Plugin
It reports each file as OK, WARN (loads but suspicious — for instance zero
terminals) or FAIL (unparseable, wrong root tag, missing bounding box), and
exits non-zero on any failure. Put it in CI if you generate `.elmt` files.
- Browse forum for scripts
- Download Terminal Block Generator
- Follow plugin installation instructions
- Test with sample project
### Rules of thumb
### 4. Join Community
- Visit **[Scripts Forum](https://qelectrotech.org/forum/viewforum.php?id=14)**
- Ask questions
- Share what you build
- **Close the project in QET before rewriting its file.** QET holds its own
in-memory model and will overwrite you on save.
- `--resave` is a cheap normaliser: load and write back, then diff, to see what
QET silently rewrites before you build a tool on an assumption about the
markup.
- Element and conductor identity is by UUID. Copying an element node without
giving it a fresh uuid produces two elements that QET considers the same one.
---
## Resources Summary
## 3. `qet_tb_generator` — what "plugin" means in QET
| Resource | Type | Purpose |
|----------|------|---------|
| **Doxygen Docs** | API Reference | C++ classes and methods |
| **XML Structure** | Format Docs | Project/element file format |
| **Scripts Forum** | Community | Share and discuss scripts |
| **Code Forum** | Community | Programming questions |
| **Source Code** | GitHub | Study implementation |
| **Building Guide** | Tutorial | Setup dev environment |
| **Contributing** | Guide | Submit code upstream |
There is one menu entry, *Launch the terminal block creation plugin*, and one
program behind it. `qet_tb_generator` is a **separate third-party program**,
distributed on PyPI, that reads and writes `.qet` files from the outside to
build terminal strips.
```bash
python -m pip install --upgrade qet_tb_generator
```
QET launches it by searching a fixed list of locations — `QETApp::dataDir() +
"/binary/"`, the current directory, `~/.qet/`, and then whatever `PATH`
resolves — and starting it as an ordinary child process. That is the entire
integration: no shared memory, no API, no callbacks. If the executable is not
on one of those paths, the menu entry cannot find it.
Community support lives on the forum:
[Scripts](https://qelectrotech.org/forum/viewforum.php?id=14) ·
[Code/Programming](https://qelectrotech.org/forum/viewforum.php?id=17)
**Writing "a plugin" therefore means writing a standalone program** that
manipulates the files, exactly as §2 describes. There is no interface to
implement and no directory to install into.
---
## Next Steps
## 4. The C++ source
1. **Understand QET files** → Read **[Project XML](project_XML)** and **[Elements XML](elements_XML)**
2. **Write a test script** → Parse a sample `.qet` file
3. **Join the community****[Scripts Forum](https://qelectrotech.org/forum/viewforum.php?id=14)**
4. **Build something useful** → Create your first automation
5. **Share it** → Contribute to community
For changing QET itself, or building a fork:
- **Doxygen API documentation:**
https://de-backer.github.io/qelectrotech-source-mirror/html/pages.html
- **Source:** https://github.com/qelectrotech/qelectrotech-source-mirror
- **[Building from source](building)** · **[Contributing](contributing)**
Orientation points, all in `sources/`:
| Class | File | Role |
|---|---|---|
| `QETProject` | `qetproject.cpp` | a project: folios, collection, load and save |
| `Diagram` | `diagram.cpp` | one folio (a `QGraphicsScene`) |
| `Element` | `qetgraphicsitem/element.cpp` | a placed symbol |
| `Conductor` | `qetgraphicsitem/conductor.cpp` | a wire |
| `Terminal` | `qetgraphicsitem/terminal.cpp` | a connection point |
| `projectDataBase` | `dataBase/projectdatabase.cpp` | the query cache — see **[The project database](project_database)** |
Note the vocabulary gap: the UI says *wire*, *page* and *symbol*; the code says
*conductor*, *diagram* and *element*. Grepping for the UI word is the usual way
to conclude wrongly that something is not implemented.
---
## Need Help?
## 5. Things that do not exist
- **[FAQ](faq)** — Common questions
- **[Forum](https://qelectrotech.org/forum/)** — Ask community
- **[GitHub Issues](https://github.com/qelectrotech/qelectrotech-source-mirror/issues)** — Report bugs
- **[Contributing](contributing)** — Get involved
Stated plainly, because this page previously claimed otherwise:
| Claim | Reality |
|---|---|
| Embedded Python scripting | No interpreter is linked or loaded. Every Python reference in the source is the `qet_tb_generator` launcher. |
| A plugin system / plugin interface | No `QPluginLoader`, no plugin ABI, nothing that loads external code. |
| `~/.local/share/QElectroTech/plugins/` and platform equivalents | QET never reads these paths. Creating them does nothing. |
| An automation API into a running instance | None. SingleApplication forwards *file arguments* to a running instance; that is all. |
Whether QET should gain a scripting interface is an open question — see the
[Vision](vision) page and the
[Development Roadmap](development_roadmap). If it does, this page will say so
when it is real, and not before.
+74 -133
@@ -1,168 +1,109 @@
# Befehlszeilen-Referenz
# Kommandozeilen-Referenz
Vollständiger Leitfaden der CLI-Optionen und -Funktionen von QElectroTech.
Überblick über die Kommandozeilenoptionen von QElectroTech.
## Grundoptionen
> **Korrigiert im September 2026.** Diese Seite beschrieb zuvor eine Option
> `--dpi` sowie Umgebungsvariablen `QET_PLUGIN_PATH` / `QET_ELEMENT_PATH`, die
> es nicht gibt, und stellte die Argumente in eine Reihenfolge, die der Parser
> nicht versteht. Alles Folgende wurde am Quellcode geprüft.
### Hilfe Anzeigen
## Allgemeine Optionen
```bash
qelectrotech --help
qelectrotech -h
```
Diese Optionen nehmen ihren Wert mit einem `=`-Zeichen entgegen.
Zeigt alle verfügbaren Optionen an.
| Option | Wirkung |
|---|---|
| `--help` | Hilfe zu den Optionen anzeigen |
| `-v`, `--version` | Version anzeigen |
| `--license` | Lizenz anzeigen |
| `--lang-dir=VERZ` | Verzeichnis mit den Sprachdateien |
### Version
Je nachdem, wie das Programm übersetzt wurde, stehen eventuell auch diese
Verzeichnis-Überschreibungen zur Verfügung: `--common-elements-dir=VERZ`,
`--common-tbt-dir=VERZ`, `--config-dir=VERZ`, `--data-dir=VERZ`. `--help` zeigt,
welche Ihre Fassung hat.
```bash
qelectrotech --version
qelectrotech -v
```
## Dateien öffnen
Zeigt die QElectroTech-Version an.
## Dateien Öffnen
### Projekt Öffnen
Eine Projektdatei wird als einfaches Positionsargument übergeben. Eine Option
`-o` oder `--open` gibt es nicht.
```bash
qelectrotech meinprojekt.qet
qelectrotech /pfad/zum/project.qet
qelectrotech projekt1.qet projekt2.qet
```
Öffnet die angegebene Projektdatei.
QET erlaubt nur eine Instanz: Ein Aufruf bei bereits laufendem QET reicht die
Dateien an das vorhandene Fenster weiter.
### Mehrere Projekte Öffnen
## Export ohne Oberfläche
Übergeben Sie eines der folgenden Flags, und QET öffnet das Projekt, erledigt
die Arbeit und endet — ohne je ein Fenster zu zeigen.
**Die Argumente sind positionsgebunden**, anders als bei den allgemeinen
Optionen. Die Form lautet stets:
```bash
qelectrotech projekt1.qet projekt2.qet projekt3.qet
qelectrotech <flag> <projekt.qet> <ausgabe>
```
Öffnet mehrere Dateien.
Das Flag steht **vor** dem Projekt. Die umgekehrte Reihenfolge funktioniert
nicht.
## Headless Export
| Flag | Ausgabe |
|---|---|
| `--export-pdf` | ein PDF, alle Folios |
| `--export-png` / `--export-svg` | ein **Verzeichnis**, ein Bild je Folio |
| `--export-bom` | CSV, Stückliste |
| `--export-wiring` | CSV, Von-Nach-Verdrahtungsliste |
| `--export-cables` | CSV, Verdrahtungsliste aus dem Dokument-XML |
| `--export-wires` | CSV, Leiternummern |
| `--export-nets` | CSV, elektrische Netze |
| `--export-links` | CSV, Querverweise |
| `--info` | strukturelles JSON (nach stdout, wenn kein Pfad angegeben ist) |
| `--resave` | neu geschriebenes `.qet` |
| `--set-titleblock` | `.qet` mit eingetragenen Schriftfeldern |
| `--check-elements` | prüft `.elmt`-Dateien oder ein Verzeichnis |
### In PDF Exportieren
Dazu `--show-terminals`, das Klemmenmarken in PDF-/PNG-/SVG-Ausgaben zeichnet.
```bash
qelectrotech projekt.qet --export-pdf ausgabe.pdf
qelectrotech --export-pdf meinprojekt.qet ausgabe.pdf
qelectrotech --export-png meinprojekt.qet bilder/
qelectrotech --export-bom meinprojekt.qet stueckliste.csv
qelectrotech --check-elements meine_elemente/
```
Exportiert das Projekt als PDF.
Eine Auflösungsoption gibt es nicht: `--export-png` zeichnet jedes Folio in der
Größe seines druckbaren Bereichs.
### In PNG Exportieren
### Rückgabewerte
`0` Erfolg · `1` die Arbeit schlug fehl · `2` falsch aufgerufen. Direkt mit
`set -e` verwendbar.
### Im Skript
```bash
qelectrotech projekt.qet --export-png ausgabe.png --dpi 300
```
Exportiert mit angegebener Auflösung in PNG.
### In SVG Exportieren
```bash
qelectrotech projekt.qet --export-svg ausgabe.svg
```
Exportiert in Vektorformat SVG.
## Steueroptionen
### Headless-Modus
```bash
qelectrotech --headless projekt.qet --export-pdf ausgabe.pdf
```
Führt ohne grafische Benutzeroberfläche aus.
### Arbeitsverzeichnis
```bash
qelectrotech --wd /pfad/zum/workdir projekt.qet
```
Legt das Arbeitsverzeichnis fest.
### Protokolldatei
```bash
qelectrotech --log-file ausgabe.log projekt.qet
```
Schreibt Logs in eine Datei.
## Automatisierung und Scripting
### Batch-Scripting
```bash
# Konvertieren Sie 100 Dateien
for f in *.qet; do
qelectrotech "$f" --export-pdf "${f%.qet}.pdf"
set -e
for f in projekte/*.qet; do
timeout 120 qelectrotech --export-pdf "$f" "pdf/$(basename "${f%.qet}").pdf"
done
```
### Exportergebnisse
Exporte erstellen Dateien im angegebenen Verzeichnis. Beispiel:
```bash
qelectrotech schematica.qet --export-pdf output/ --dpi 150
```
Erstellt `output/schematica.pdf` mit 150 DPI Auflösung.
`QT_QPA_PLATFORM=offscreen` genügt; Xvfb wird nicht benötigt. Setzen Sie immer
eine Zeitgrenze: Ein mit einer älteren Version gespeichertes Projekt kann einen
modalen Dialog auslösen.
## Umgebungsvariablen
```bash
# Plugin-Verzeichnis festlegen
export QET_PLUGIN_PATH=/pfad/zu/plugins
QET definiert keine eigenen Umgebungsvariablen für Plugins oder Elemente.
Verwenden Sie die Optionen `--common-elements-dir=` und Verwandte oben, sofern
Ihre Fassung sie anbietet.
# Element-Verzeichnis festlegen
export QET_ELEMENT_PATH=/pfad/zu/elements
## Weiterführend
# QET starten
qelectrotech projekt.qet
```
## Häufige Beispiele
### Batch-Konvertierung
```bash
#!/bin/bash
for qet in *.qet; do
qelectrotech "$qet" --headless --export-pdf "${qet%.qet}.pdf"
echo "Konvertiert: $qet"
done
```
### Mit Ordner Exportieren
```bash
qelectrotech projekt.qet \
--headless \
--export-pdf ./exports/diagramm.pdf \
--dpi 300
```
### Automatisierte Verarbeitung
```bash
# Verarbeiten, exportieren und archivieren
qelectrotech data/schaltung.qet \
--headless \
--export-svg output/schaltung.svg
```
## Ressourcen
- **[Beitragen](contributing-DE)** — Beitragsanleitung
- **[API-Referenz](api_reference-DE)** — Python-Scripting und Plugins
- **[Forum](https://forum.qelectrotech.org/)** — Gemeinschafts-Support
---
**[🌐 Sprache wählen](languages)** — English · Français · Deutsch
- **[QElectroTech automatisieren](api_reference-DE)** — die Kommandozeile im
Detail, das XML-Format der Dateien, und was es nicht gibt
- **[Aus Quellcode bauen](building-DE)**
+82 -140
@@ -1,168 +1,110 @@
# Référence Interface de Ligne de Commande
# Référence de la ligne de commande
Guide complet des options et fonctionnalités de l'interface CLI de QElectroTech.
Guide des options en ligne de commande de QElectroTech.
## Options de Base
> **Corrigé en septembre 2026.** Cette page décrivait auparavant une option
> `--dpi` et des variables d'environnement `QET_PLUGIN_PATH` /
> `QET_ELEMENT_PATH` qui n'existent pas, et plaçait les arguments dans un ordre
> que l'analyseur ne comprend pas. Tout ce qui suit a été vérifié sur le code
> source.
### Affichage de l'Aide
## Options générales
Ces options prennent leur valeur avec un signe `=`.
| Option | Effet |
|---|---|
| `--help` | Afficher l'aide sur les options |
| `-v`, `--version` | Afficher la version |
| `--license` | Afficher la licence |
| `--lang-dir=DOSSIER` | Dossier contenant les fichiers de langue |
Selon la façon dont le binaire a été compilé, ces redéfinitions de dossiers
peuvent aussi être disponibles : `--common-elements-dir=DOSSIER`,
`--common-tbt-dir=DOSSIER`, `--config-dir=DOSSIER`, `--data-dir=DOSSIER`.
Lancez `--help` pour voir celles dont dispose votre version.
## Ouvrir des fichiers
Un fichier projet se donne comme simple argument positionnel. Il n'existe pas
d'option `-o` ni `--open`.
```bash
qelectrotech --help
qelectrotech -h
qelectrotech monprojet.qet
qelectrotech projet1.qet projet2.qet
```
Affiche toutes les options disponibles.
QET n'autorise qu'une seule instance : lancer la commande alors que QET tourne
déjà transmet les fichiers à la fenêtre existante.
### Version
## Export sans interface
Passez l'un des indicateurs ci-dessous et QET ouvre le projet, fait le travail
et se termine, sans jamais afficher de fenêtre.
**Les arguments sont positionnels**, contrairement aux options générales. La
forme est toujours :
```bash
qelectrotech --version
qelectrotech -v
qelectrotech <indicateur> <projet.qet> <sortie>
```
Affiche la version de QElectroTech.
L'indicateur vient **avant** le projet. L'ordre inverse ne fonctionne pas.
## Ouvrir des Fichiers
| Indicateur | Sortie |
|---|---|
| `--export-pdf` | un PDF, tous les folios |
| `--export-png` / `--export-svg` | un **dossier**, une image par folio |
| `--export-bom` | CSV, nomenclature |
| `--export-wiring` | CSV, liste de câblage de-à |
| `--export-cables` | CSV, liste de câblage issue du XML du document |
| `--export-wires` | CSV, numéros de conducteurs |
| `--export-nets` | CSV, réseaux électriques |
| `--export-links` | CSV, renvois de folio |
| `--info` | JSON structurel (sur stdout si aucun chemin n'est donné) |
| `--resave` | `.qet` réécrit |
| `--set-titleblock` | `.qet` avec champs de cartouche renseignés |
| `--check-elements` | valide des fichiers `.elmt` ou un dossier |
### Ouvrir un Projet
Plus `--show-terminals`, qui dessine les marqueurs de bornes dans les sorties
PDF/PNG/SVG.
```bash
qelectrotech myproject.qet
qelectrotech /chemin/vers/project.qet
qelectrotech --export-pdf monprojet.qet sortie.pdf
qelectrotech --export-png monprojet.qet images/
qelectrotech --export-bom monprojet.qet nomenclature.csv
qelectrotech --check-elements mes_elements/
```
Ouvre le fichier de projet spécifié.
Il n'y a pas d'option de résolution : `--export-png` rend chaque folio à la
taille de sa zone imprimable.
### Ouvrir Plusieurs Projets
### Codes de retour
`0` succès · `1` le travail a échoué · `2` erreur d'appel. Utilisables
directement avec `set -e`.
### Dans un script
```bash
qelectrotech project1.qet project2.qet project3.qet
```
Ouvre plusieurs fichiers.
## Export Headless
### Exporter en PDF
```bash
qelectrotech project.qet --export-pdf output.pdf
```
Exporte le projet en PDF.
### Exporter en PNG
```bash
qelectrotech project.qet --export-png output.png --dpi 300
```
Exporte en PNG avec résolution spécifiée.
### Exporter en SVG
```bash
qelectrotech project.qet --export-svg output.svg
```
Exporte en format vectoriel SVG.
## Options de Contrôle
### Mode Headless
```bash
qelectrotech --headless project.qet --export-pdf output.pdf
```
Exécute sans interface graphique.
### Répertoire de Travail
```bash
qelectrotech --wd /chemin/vers/workdir project.qet
```
Définit le répertoire de travail.
### Fichier de Log
```bash
qelectrotech --log-file output.log project.qet
```
Écrit les logs dans un fichier.
## Automatisation et Scripting
### Scripting Batch
```bash
# Convertir 100 fichiers
for f in *.qet; do
qelectrotech "$f" --export-pdf "${f%.qet}.pdf"
set -e
for f in projets/*.qet; do
timeout 120 qelectrotech --export-pdf "$f" "pdf/$(basename "${f%.qet}").pdf"
done
```
### Résultats d'Export
`QT_QPA_PLATFORM=offscreen` suffit ; Xvfb n'est pas nécessaire. Prévoyez
toujours un délai d'expiration : un projet enregistré par une version
antérieure peut faire apparaître une fenêtre modale.
Les exports créent des fichiers dans le répertoire spécifié. Exemple :
## Variables d'environnement
```bash
qelectrotech schematic.qet --export-pdf output/ --dpi 150
```
QET ne définit pas de variable d'environnement propre pour les greffons ou les
éléments. Utilisez les options `--common-elements-dir=` et compagnie ci-dessus
lorsque votre version les propose.
Crée `output/schematic.pdf` avec résolution 150 DPI.
## Pour aller plus loin
## Variables d'Environnement
```bash
# Définir le répertoire des plugins
export QET_PLUGIN_PATH=/chemin/vers/plugins
# Définir le répertoire des éléments
export QET_ELEMENT_PATH=/chemin/vers/elements
# Lancer QET
qelectrotech project.qet
```
## Exemples Courants
### Conversion par Lot
```bash
#!/bin/bash
for qet in *.qet; do
qelectrotech "$qet" --headless --export-pdf "${qet%.qet}.pdf"
echo "Converti: $qet"
done
```
### Exporter avec Dossier
```bash
qelectrotech project.qet \
--headless \
--export-pdf ./exports/diagram.pdf \
--dpi 300
```
### Traitement Automatisé
```bash
# Traiter, exporter et archiver
qelectrotech data/circuit.qet \
--headless \
--export-svg output/circuit.svg
```
## Ressources
- **[Contribuer](contributing-FR)** — Guide de contribution
- **[Référence API](api_reference-FR)** — Scripting et plugins Python
- **[Forum](https://forum.qelectrotech.org/)** — Support communautaire
---
**[🌐 Choisir la Langue](languages)** — English · Français · Deutsch
- **[Automatiser QElectroTech](api_reference-FR)** — la ligne de commande en
détail, le format XML des fichiers, et ce qui n'existe pas
- **[Construire depuis les sources](building-FR)**
+61 -51
@@ -144,9 +144,19 @@ qelectrotech -h
| Option | Usage | Description |
|--------|-------|-------------|
| `--help` or `-h` | `qelectrotech --help` | Show help message |
| `--version` or `-v` | `qelectrotech --version` | Show version number |
| `--open` or `-o` | `qelectrotech -o project.qet` | Open project file (same as positional) |
| `--help` | `qelectrotech --help` | Show help message |
| `--version`, `-v` | `qelectrotech -v` | Show version number |
| `--license` | `qelectrotech --license` | Show the licence |
| `--lang-dir=DIR` | `qelectrotech --lang-dir=/opt/qet/lang` | Directory holding the translation files |
Depending on how the binary was compiled, these directory overrides may also be
available: `--common-elements-dir=DIR`, `--common-tbt-dir=DIR`,
`--config-dir=DIR`, `--data-dir=DIR`. Run `--help` to see which your build has.
**Note the two different syntaxes.** These options take their value with an
`=` sign. The export flags in the next section take theirs *positionally*.
A project file is given as a plain positional argument — there is no `-o` or
`--open` option.
### Project File
@@ -162,20 +172,41 @@ qelectrotech project1.qet project2.qet
## Export & Batch Operations
**Note:** Current CLI export support is limited. For batch export, use:
1. **GUI export** (File → Export)
2. **Python scripting** via **[API Reference](api_reference)**
3. **Script plugins** (Terminal Block Generator, custom scripts)
QET has a **headless export mode**: pass one of the flags below and it opens the
project, does the work and exits without showing a window.
### Future CLI Features (QET 2.0)
```bash
qelectrotech --export-pdf myproject.qet out.pdf
```
Planned improvements include:
- `--export` or `-e` — Export to format (PDF, PNG, SVG, DXF)
- `--batch` — Process multiple files
- `--output` — Specify output directory
- Headless mode for automated workflows
Arguments are **positional**, not `--flag=value`. The shape is always
`qelectrotech <flag> <project.qet> <output>`.
See **[Development Roadmap](development_roadmap)** for timeline.
| Flag | Output |
|---|---|
| `--export-pdf` | one PDF, all folios |
| `--export-png` / `--export-svg` | a directory, one image per folio |
| `--export-bom` | CSV bill of materials |
| `--export-wiring` | CSV from-to wiring list |
| `--export-cables` | CSV wiring list, built from the document XML |
| `--export-wires` | CSV conductor numbers |
| `--export-nets` | CSV electrical nets |
| `--export-links` | CSV cross-references |
| `--info` | JSON structural dump (stdout if no output path) |
| `--resave` | rewritten `.qet` |
| `--set-titleblock` | `.qet` with title-block fields stamped |
| `--check-elements` | validates `.elmt` files or a directory of them |
Plus `--show-terminals`, which paints terminal markers into PDF/PNG/SVG output.
Exit codes: `0` success, `1` the work failed, `2` called wrongly — so these are
safe to chain in a script with `set -e`.
`QT_QPA_PLATFORM=offscreen` is enough; no Xvfb is needed. Always set a timeout
in automated runs.
Full detail, including the `--set-titleblock` assignment syntax:
**[Automating QElectroTech](api_reference)**.
---
@@ -256,9 +287,14 @@ wait
### Advanced Automation
For complex automation:
1. Use **Python scripting** to manipulate XML files
2. Use **plugins** for custom functionality
3. See **[API Reference](api_reference)** for details
1. Use the export flags above — they cover PDF, images, BOM, wiring lists,
nets, cross-references and title-block stamping
2. For anything they do not cover, write a program of your own that reads and
writes the `.qet` / `.elmt` XML directly
3. See **[Automating QElectroTech](api_reference)** for both
QET has no embedded scripting language and no plugin system; automation is the
command line plus your own tools.
---
@@ -424,43 +460,17 @@ wait # Wait for all to finish
## Limitations & Workarounds
### Current Limitations
| Limitation | Workaround |
|-----------|-----------|
| No headless/batch export | Use Python scripting to process XML |
| No PDF export via CLI | Use GUI export or scripting |
| No diagram generation via CLI | Use XML manipulation or plugins |
| Limited CLI options | Use API/scripting for complex tasks |
| No CLI option to create or edit a diagram | Edit the `.qet` XML directly — see **[Automating QElectroTech](api_reference)** |
| One project per invocation | Loop in the shell; each run is independent |
| No DXF export from the CLI | Use GUI export (File → Export) |
| No embedded scripting language | Write an external program against the XML |
### Recommended Alternatives
**For automation:** Use **[Python scripting](api_reference#scripting)** to:
- Parse project XML
- Extract data
- Generate reports
- Batch process files
**For complex workflows:** Use **[Plugins](api_reference#plugins)**:
- Terminal Block Generator (example)
- Custom automation plugins
- Integration with other tools
---
## Future CLI Enhancements
### Planned for QET 2.0
Potential improvements:
- `--export` — Batch export to various formats
- `--headless` — Run without GUI
- `--batch` — Process multiple files
- `--script` — Run automation scripts
- `--convert` — Convert between formats
- Better exit codes and logging
See **[Development Roadmap](development_roadmap)** for details.
> **Corrected September 2026.** This section previously claimed QET had no
> headless export and no CLI PDF export, and pointed readers at Python
> scripting and plugins that do not exist. Headless export has shipped for some
> time — see the export flags above.
---
+1 -1
@@ -275,7 +275,7 @@ See **[Issues](https://github.com/qelectrotech/qelectrotech-source-mirror/issues
**A:** Try:
1. **Reinstall:** Remove and reinstall QElectroTech
2. **Check logs:** Look for error messages on startup
3. **Disable plugins:** If crash on startup, plugins may be issue
3. **Try a clean profile:** Start from a fresh configuration to rule out a bad setting
4. **Clear cache:** Remove ~/.qelectrotech/ (Linux) or AppData (Windows)
5. **Update Qt:** Ensure Qt libraries are current
+8 -3
@@ -229,11 +229,16 @@ Beyond electrical diagrams, QET handles:
### Script & Automation
- **Python scripting** — Automate repetitive tasks
- **Batch operations** — Process multiple files
- **Custom workflows** — Extend with plugins
- **Headless command line** — Export PDF, images, BOM, wiring lists, nets and
cross-references without opening a window
- **Batch operations** — Loop the CLI over many projects, with real exit codes
- **Open XML formats** — `.qet` and `.elmt` are plain XML, so external tools can
read and write them
- **Integration** — Combine with other tools
QET has no embedded scripting language and no plugin system; see
**[Automating QElectroTech](api_reference)**.
### Element Libraries
- **Organize collections** — Group related symbols
+2 -2
@@ -117,7 +117,7 @@ QElectroTech now serves:
- User-contributed elements and libraries
- Shared projects and tutorials
- DXF import capabilities
- Python scripting and plugin development
- External tooling built on the open XML formats (e.g. `qet_tb_generator`)
---
@@ -153,7 +153,7 @@ From basic diagram drawing to:
- Element libraries (8,000+ symbols)
- DXF import/export
- Terminal strip management
- Python scripting support
- A headless command line for export and batch work
- Custom element creation
- Multi-diagram projects
+8 -1
@@ -575,7 +575,14 @@ Siehe **[Elemente erstellen](elements_XML)** für detaillierte Anweisungen zu:
### Scripting und Automatisierung
*Informationen zu Python-Scripting-Unterstützung (wenn vollständig dokumentiert)*
QET hat **keine eingebettete Skriptsprache**. Automatisiert wird von außen:
- die **Kommandozeile ohne Oberfläche**`--export-pdf`, `--export-bom`,
`--export-wiring` und weitere, mit echten Rückgabewerten
- **direktes Bearbeiten des XML** — `.qet` und `.elmt` sind gewöhnliches XML
Siehe **[QElectroTech automatisieren](api_reference-DE)** und die
**[Kommandozeilen-Referenz](cli_reference-DE)**.
---
+9 -1
@@ -577,7 +577,15 @@ Voir **[Créer des Éléments](elements_XML)** pour les instructions détaillée
### Scripting et Automatisation
*Informations sur le support de script Python (une fois complètement documenté)*
QET n'a **aucun langage de script embarqué**. L'automatisation se fait depuis
l'extérieur :
- la **ligne de commande sans interface**`--export-pdf`, `--export-bom`,
`--export-wiring` et d'autres, avec de vrais codes de retour
- l'**édition directe du XML** — `.qet` et `.elmt` sont du XML ordinaire
Voir **[Automatiser QElectroTech](api_reference-FR)** et la
**[Référence ligne de commande](cli_reference-FR)**.
---
+8 -1
@@ -575,7 +575,14 @@ See **[Creating Elements](elements_XML)** for detailed instructions on:
### Scripting & Automation
*Information on Python scripting support (when fully documented)*
QET has **no embedded scripting language**. Automation is done from the outside:
- the **headless command line**`--export-pdf`, `--export-bom`,
`--export-wiring` and more, with real exit codes for use in scripts
- **direct XML editing** — `.qet` and `.elmt` are plain XML
See **[Automating QElectroTech](api_reference)** and the
**[CLI Reference](cli_reference)**.
---