Skip to content
ispyisail edited this page Oct 7, 2026 · 5 revisions

Variables and formulas

Several fields in QElectroTech accept a formula — text with % variables that QET substitutes when it draws. %f-%l%c on an element label becomes 3-B7. %id/%total in the sheet field becomes 3/12.

The catch is that there is no single variable language. Five different places accept formulas, each resolves a different set, and a variable that works in one is silently left as literal text in another. That is what this page is for.

Sources: sources/autoNum/assignvariables.cpp (AssignVariables, replaceVariable), sources/bordertitleblock.cpp, sources/titleblocktemplate.cpp (interpreteVariables).


1. Where formulas are accepted

Where Set in Resolves
Element label element information, or Project properties → element auto-numbering position, sheet, sequences, %{…} info
Conductor text conductor properties → formula, or conductor auto-numbering position, sheet, sequences, wire properties
Sheet field sheet properties → Sheet only %autonum, %id, %total
Title block cells the .titleblock template whatever is in the title-block context
Cross-reference labels Project properties → cross-references same as element labels

2. Sheet and position variables

These resolve on element labels, conductor texts and cross-reference labels.

Variable Becomes
%f sheet index, 1-based
%id the same sheet index — %f and %id are identical here
%F the sheet field, i.e. whatever the sheet's Sheet setting renders to
%total total number of sheets in the project
%M plant (installation) of the sheet
%LM location / machine (locmach) of the sheet
%l the row letter of the element's position in the border
%c the column number of the element's position
%prefix the element's prefix

%f and %F are not interchangeable

%f is the sheet's index — a plain number. %F inserts the sheet field, which is itself a formula. QET's default for that field is %id/%total, so on sheet 3 of 12:

%f  →  3
%F  →  3/12

Both then read naturally in a label, which is why the difference goes unnoticed until someone changes the sheet field and every element label changes shape with it. If you want the number, use %f.

%c counts from 0 or 1 depending on a preference

The column number comes out one lower when the columns start at 0 preference is set. The same project opened by two people with different settings produces different labels. If labels must be stable across a team, agree that setting first.


3. Wire variables

Only on conductor formulas:

Variable Becomes
%wf conductor function
%wv tension / protocol
%wc wire colour
%ws wire section

4. Sequence variables

Auto-numbering supplies numbered sequences. Each comes in a per-project and a per-sheet flavour, and each takes a trailing index — _1 is the first sequence you defined in that numbering scheme, _2 the second, and so on.

Family Per project Per sheet
Unit %sequ_1 %sequf_1
Ten %seqt_1 %seqtf_1
Hundred %seqh_1 %seqhf_1
Alphabetic %seqa_1 —
Wrap %seqw_1 —

A sequence variable whose index does not exist in the current numbering scheme is left in the text as-is. Seeing a literal %sequ_2 on a sheet means the scheme defines only one sequence, not that numbering failed.


5. Element information variables — %{…}

Braced variables pull from the element's own information fields:

%{label} %{manufacturer_reference}

Commonly used: %{label}, %{plant}, %{location}, %{function}, %{comment}, %{description}, %{designation}, %{manufacturer}, %{manufacturer_reference}, %{machine_manufacturer_reference}, %{supplier}, %{quantity}, %{unity}.

Also available: %{auxiliary1} … %{auxiliary4} and their description_, designation_, manufacturer_, manufacturer_reference_, machine_manufacturer_reference_, supplier_, quantity_ and unity_ variants; the PLC fields %{plc_type}, %{plc_address}, %{plc_function}, %{plc_comment}, %{plc_crossref}, %{plc_t1} … %{plc_t4}, %{plc_tc}; the conductor fields %{conductor_color}, %{conductor_section}, %{tension_protocol}; and %{void}, which resolves to nothing.

The list is hard-coded, and eight fields are missing from it

%{…} substitution is a fixed list in AssignVariables::replaceVariable(), not a lookup over every information field. QETInformation::elementInfoKeys() lists 64 information keys; 63 braced variables are recognised, and they do not fully overlap.

Two keys are absent by design: formula (it is the formula) and xref. Eight more have no braced variable at all:

%{category}  %{model}  %{notes}  %{voltage_rating}  %{current_rating}
%{width}  %{height}  %{depth}

You can fill any of these in on an element, but none of the eight is in the substitution list, so they stay on the drawing as literal text. Put the value in another field until this is fixed.

The first five arrived with the smart-device metadata fields, and width, height and depth (the device's size in mm) with the element dimension fields; none of them was added to replaceVariable().

The four %{machine_manufacturer_reference_auxiliary1} … 4 variables were missing too, until PR #1236 (merged 2 October 2026). In builds made since then they resolve like the others; in older builds they stay on the drawing as literal text.

Measured against master b48525842. Earlier revisions of this page said 57, then 61 keys — each was correct when written, and the drift is why counting from the source matters.


6. Sheet field variables

The sheet field is the exception on this page: it is resolved by a different function and understands three variables only.

Variable Becomes
%id this sheet's index
%total number of sheets
%autonum the sheet auto-numbering value

The default is %id/%total. %f, %l, %c, %M, %LM and %{…} do nothing here — they are left in the field verbatim and will be printed on every sheet exactly as typed. This is the single most common variable disappointment in QET.


7. Title block variables

Title block template cells use their own mechanism: every key in the title block's context is substituted, in both the braced and bare forms — %{author} and %author both work.

The standard keys are the sheet's own information fields: title, author, filename, folio, plant, locmach, indexrev, date, display_folio. Project properties and any custom fields you add to the sheet are substituted too, as are the project's own projecttitle, projectfilename, savedfilename, saveddate and the rest — listed in Title block templates.

A placeholder in the template that nothing gives a value to — typically a custom variable not filled in yet — is drawn as nothing, not as its own name.

Two details worth knowing:

  • Keys are substituted longest first, deliberately. Without that, a key named plant would eat the beginning of %plantcode and leave code stranded.
  • Only the braced form %{name} can be discovered — the template editor's list of variables in use is built by scanning for %{…}. A bare %name still resolves, but nothing can enumerate it, so prefer the braced form in templates.

8. Substitution is one pass, in a fixed order

Formulas are not evaluated recursively. QET does a sequence of ordinary text replacements, and the order is fixed:

  1. %F, %f, %id, %total, %M, %LM
  2. %c, %l, %prefix (elements) or %wf, %wv, %wc, %ws (conductors)
  3. title-block fields, then project properties, in both %{name} and %name forms
  4. sequences

Two consequences:

  • %F works because it is expanded first. It inserts the sheet field, which may itself contain %id and %total — and those are substituted in the same step, just after. Anything the sheet field contains that step 1 does not know about will survive to the drawing as literal text.
  • An unknown variable is never an error. It is simply not replaced. A label showing %seqh_3 or %{category} is QET telling you that variable is not resolvable here.

9. Quick reference

I want… Use Where it works
the sheet number %f element / conductor / xref labels
the sheet number in the sheet field %id sheet field only
sheet number and total, e.g. 3/12 %F element / conductor / xref labels
the element's grid position %l%c element labels
an incrementing number %sequ_1 element / conductor labels
an element's part number on the drawing %{manufacturer_reference} dynamic texts, labels
the plant on a title block %{plant} or %plant title block templates

See also: Linking elements · The project database · Project XML

Getting Started

Home

🌐 Languages — English · Français · Deutsch

Downloads

Windows without admin rights — the portable archive, no installer

Quick Start Guide

User Manual

FAQ

Tips & Tricks

Guides

Conductors — wire properties, what feeds which export, cables, and hops where wires cross

Wires per terminal — limit the wires on a terminal, chain wiring instead of stars

Printing and exporting — paper, PDF, images, and what each path does differently

Linking elements — master, slave, terminal

PLC modules — I/O tables and linking a wire to a specific point

Using the element editor — drawing tools, saving, checks

Grid size and element size — why symbols aren't all the same scale, and scaling one without leaving the grid

Preferences reference — what each settings page does

Saving and loading settings — your whole setup in one file, to copy or keep

Keyboard-only control — mouseless QET, and what still needs a mouse

Mouse modifiers — what Shift, Ctrl and Alt change while you drag

3D mouse — SpaceMouse pan, zoom and buttons

Aligning items — snap symbols back to the grid, or line them up

Pictures on a sheet — labels, crop, transparency, what they cost in the file

Arcs and curved wires — the Arc tool, pulling an arc in or out, rounding a corner with a fillet, dashed arcs for lighting layouts

Grouping items — select, move and copy several items as one

Finding your place on a sheet — go to a cell like B13 or 4-B7, keep the headers in sight, show the cell limits, zoom and pan

Showing and hiding kinds of items — hide texts, wire numbers, shapes, pictures, tables or cross-references on every sheet

Drawing faster — place without dragging, the S shortcut bar, command search, gestures

Customising QElectroTech — keys, toolbar size and contents, the gesture ring (partly pending)

Managing collections — folders, writability, building your own shortlist

Templates — reusable multi-element blocks, placed by double-click or drag

Search & Replace — bulk property changes

Building a nomenclature query — the BOM/summary table builder

Linking wires across pages — sheet reports

Variables & formulas — %f, %{label}, sequences

Auto-numbering — schemes, sequences, freezing

Terminal strips — strips, levels, bridges

Title block templates — the .titleblock format

Importing EPLAN parts (.edz) — EPLAN Data Portal

DXF import & export — two unrelated features, one format; command-line export and layers

The project database — the in-memory SQLite cache

File formats
Elements XML
Project XML
Development

Building from Source

Contributing Code

Automating QET — CLI, XML formats, external tools

CLI Reference — command line usage

JavaScript Scripting — --run, geometry editing, undo

MCP server — let an AI assistant read, verify and edit projects

Connecting an AI assistant — setup for Claude, Copilot, Gemini, Codex, Cursor, LM Studio

Script buttons — stored scripts with an icon, by hand or by an assistant

Live mode — an assistant working in the open project while you watch

Macro recorder — record a task by hand, for an assistant to script

Development Roadmap

Vision — proposal, under discussion

Developer Tools

About

Features

History

Community

License

Contributing to this Wiki

Clone this wiki locally