Example: Qucs schematic → ROOM → round-trip

The qucs_to_room program — schematic import, save, reload, export

1. Run (VS Code)

Tasks: Run Task → Example: Qucs to ROOM

2. Run (command line)

.\build\qucs_to_room.exe examples\qucs_to_room\data\rc_lowpass.sch examples\qucs_to_room\output\schematic.room
ArgumentDescription
input.schQucs schematic (default: examples/qucs_to_room/data/rc_lowpass.sch)
output.roomROOM file — any path/name, e.g. schematic.room
dump.txtText dump (optional)
roundtrip.schExported Qucs file after reload (optional)

3. Source code

examples/qucs_to_room/main.cpp

#include "database.h"
#include "qucs_importer.h"
#include "qucs_exporter.h"
#include "text_dump.h"

room::QucsImporter importer;
room::Database db = importer.importFile("rc_lowpass.sch");

db.saveToFile("schematic.room");

room::Database loaded = room::Database::loadFromFile("schematic.room");

room::QucsExporter exporter;
exporter.exportCell(loaded, "rc_lowpass", "schematic_roundtrip.sch");

4. Data flow

Qucs .sch (text) │ ▼ QucsImporter::importFile() │ Components → Instance, Wires → Net/Term ▼ Database → Cell → CellContent(schematic).payload.schematic.block │ ├─► Database::saveToFile() → schematic.room ├─► Database::loadFromFile() → reload check └─► QucsExporter::exportCell() → schematic_roundtrip.sch

5. Qucs → ROOM mapping

QucsROOM
<Components> lineInstance (cellName = Qucs type, qucs.instName = R1, C1, …)
<Wires> labelNet name
Wire endpointsTerm positions; dbuPerEditorUnit=1 (1 DBU = 1 Qucs grid unit)
Coordinate scaleCellContent::dbuPerEditorUnit() = 1
View typeViewType::Schematic

6. Attached primitive libraries (LibMan / Qucs-S)

When a project attaches tech or common libraries, LibMan sets environment variables consumed by PrimitiveResolver and QucsExporter::Options:

VariablePurpose
CORE_PRIMITIVE_LIBS_FILENewline-separated list of *.symbol.room paths (preferred for large libraries)
LIBMAN_TECH_LIBRARYLogical library names (commonLib;sg13g2_pr)
QUCS_PRIMITIVE_LIBQucs <Lib> name for PDK cells

On export to Qucs, passives map to native devices (res → R). PDK and hierarchy cells use <Lib> with ROOM symbol geometry. Xschem-only decorations (lab_wire, code_shown) are omitted in Qucs.

7. Sample text dump

cell "rc_lowpass"
  type schematic dbuPerMicron=1.000 dbuPerEditorUnit=1.000
  shapes=0 instances=4 nets=3
    instance -> "R" at (280,200)
    instance -> "C" at (480,200)
    net "N1" sig=signal terms=4

Limitations

See also: GDS layout import example · Coordinate scale