CH NEO-ZÜRICH EDITION
WEATHER · OVERCAST 3°C
BLEND OF THE DAY · 07/ROGUE
EST. 2027
THE AEC CYBER MORNING NEWS

PAZ Kaffi

DESIGN · DEMOLITION · CAFFEINE · DISPATCH
EDITION 1124 · 24 November 2026
BROADCAST 04:42 CET
2,400 BROADSHEETS PRINTED
READ TIME · 47 MIN
Eight Characters per Layer: a 67-Line Rhino Script Checks Your Model Before Hand-Over
ACADEMY
FRAME · 06:55
24-11-2026

Eight Characters per Layer: a 67-Line Rhino Script Checks Your Model Before Hand-Over

A 67-line Rhino 8 Python script tests every layer against Kanton Zug's 8-character key on SIA 2014, counts objects and writes a CSV before hand-over.

Phase end on a Swiss project tends to look the same. The drawings are signed off, the client’s CAD guideline is open in a second window, and someone scrolls the Rhino Layers panel hunting for Layer 01 and a1m1—e before the files leave the office. Layer 01 is not a layer name. It is a confession. This tutorial replaces the scroll with 67 lines of Python 3 in the Rhino 8 ScriptEditor. The script tests every layer name against an 8-character client key, counts the objects on each layer, writes a CSV next to the .3dm and, if you ask it to, fixes the obvious near-misses.

The norm in one paragraph

The Swiss reference is SIA 2014:2017, the Merkblatt CAD-Datenaustausch – Layerstruktur und Layerschlüssel (SNR 592014:2017). It has 28 pages, has been valid since 1 September 2017 and replaces the 1996 edition. Its foreword makes the decisive move in one sentence: “Entgegen der Ausgabe 1996 lässt das vorliegende Merkblatt die Struktur offen …” Unlike 1996, it prescribes no element breakdown, and it follows ISO 13567-1. That openness is the work of the Kommission SIA 2014 under its president Christoph Rosenthaler, dipl. Bau-Ing. ETH/SIA, from Muttenz, with CADexchange, SIA KIN and suissetec at the table. Their names rarely reach a hand-over meeting, yet every clean layer list in the country leans on them. Because the norm leaves the structure open, clients write their own keys. The Canton of Zug’s Baudirektion Hochbauamt did exactly that. According to its HBA Standard – Richtlinie für den CAD-Datenaustausch, version 2.1 from May 2023, the layer structure “basiert auf der EKG-Gliederung gemäss SIA-Merkblatt 2014”. Office structures are fine internally, but they must be converted “zumindest bei Abschluss einer Projektphase”, and non-conforming layers are deleted or converted at delivery. So this is Zug’s key: one client’s application of SIA 2014, not “the SIA key”.

Decoding A1E41–E

Zug’s annex 7.1 a fixes the key at 8 characters in three fields. Take the guideline’s own example, A1E41--E:

  • A1 is characters 1–2, the agent. The allowed list is A1, FG, IH, IL, IS, IE, IT, I- and VA.
  • E41– is characters 3–7, the content, following the CRB EKG of 1995. It is one letter followed by digits, padded with dashes.
  • E is character 8, the graphic type: E Element, D Bemassung, G Geometrie, T Text, P Plankopf/Planrand, H Schraffuren, X Sonstiges.

Zug keeps the key to eight characters “aus Gründen der Übersichtlichkeit und der Kompatibilität zu diversen CAD-Programmen”. A rule set that fits in three bullets is a rule set a loop can check.

←TODAY: Zug’s HBA guideline v2.1 asks for 8-character layers at every phase close. →3012: A layer key stored as plain text still opens when every vendor of today has gone dark. Fulcrum: A key that is short enough to read is also short enough to test, and a tested key outlives the software that wrote it.

The Tool: The tool is Rhino 8’s ScriptEditor running CPython 3 against RhinoCommon, the .NET SDK from Robert McNeel & Associates. The scriptcontext module hands your script the open document as sc.doc, so the layer table, the object table and the file path are each one attribute away. It turns a guideline PDF into a check that runs in seconds on any project. PAZ Academy is a Rhino centre in Switzerland, and this is the kind of small, readable office tool the PAZ-Rhino movement asks offices to share.

Setup:

# Rhino 8. At the Rhino command line type:
ScriptEditor
# In the editor, create a new Python 3 file.
# Paste the 67 lines below and save as:
#   layer_key_check.py
# Work on a COPY of the model first, for example:
#   Projekt_Musterhaus.3dm  ->  Projekt_Musterhaus_test.3dm
# Press Run in the ScriptEditor.
# You should see a summary line in the output panel and
#   Projekt_Musterhaus_test_layers.csv  next to the .3dm

First steps:

  1. Open the copy of your project and run the script with FIX_NEAR_MISSES = False. Nothing in the model changes.
  2. Read the printed list. Every line shows a layer, its object count and the reason it fails the key.
  3. Open the CSV in Excel. The ; delimiter and the UTF-8 BOM mean Swiss Excel splits the columns and keeps “Tür” intact.
  4. Only when the report looks right, set the flag to True, run it again and compare the two reports.

The code, explained:

#! python 3
"""Layer key check - Rhino 8 ScriptEditor (Python 3). Tests every layer
against an 8-character key (Kanton Zug HBA, on SIA 2014 / CRB EKG) and
writes a CSV next to the .3dm. Optional: fix obvious near-misses."""
import csv
import os
import re
import scriptcontext as sc

# --- the key: edit these for your client or office -----------------------
AGENTS = {"A1", "FG", "IH", "IL", "IS", "IE", "IT", "I-", "VA"}   # chars 1-2
GRAPHIC = {"E", "D", "G", "T", "P", "H", "X"}                     # char 8
CONTENT = re.compile(r"^[A-Z-][0-9-]{4}$")                         # chars 3-7
EXTRA = {"Raum", "Geschoss", "Tür", "Parkfeld", "EBF"}             # allowed as-is
FIX_NEAR_MISSES = False      # True: upper-case + strip spaces where that fixes it

def check(name):
    """Layer name -> '' if it fits the key, else the reason."""
    if name in EXTRA:
        return ""
    if len(name) != 8:
        return "{} characters, needs 8".format(len(name))
    if name[:2] not in AGENTS:
        return "agent '{}' not in list".format(name[:2])
    if not CONTENT.match(name[2:7]):
        return "content '{}' is not EKG letter + 4 digits/dashes".format(name[2:7])
    if name[7] not in GRAPHIC:
        return "graphic type '{}' unknown".format(name[7])
    return ""

def suggest(name):
    """Cheap fixes only: strip spaces, upper-case. None if still wrong."""
    s = name.replace(" ", "").upper()
    return s if s != name and check(s) == "" else None

def main():
    rows, bad, fixed = [], 0, 0
    taken = {l.Name for l in sc.doc.Layers if not l.IsDeleted}
    for layer in sc.doc.Layers:
        if layer.IsDeleted or layer.IsReference:
            continue
        objs = sc.doc.Objects.FindByLayer(layer) or []
        reason = check(layer.Name)
        fix = suggest(layer.Name) if reason else None
        nested = "yes" if "::" in layer.FullPath else ""
        if reason and fix and FIX_NEAR_MISSES and fix not in taken:
            layer.Name = fix
            sc.doc.Layers.Modify(layer, layer.Index, True)
            taken.add(fix)
            reason, fixed = "fixed -> " + fix, fixed + 1
        elif reason:
            bad += 1
        rows.append([layer.FullPath, len(objs), nested, reason or "OK", fix or ""])
    path = sc.doc.Path
    out = (os.path.splitext(path)[0] if path else os.path.expanduser("~/layer_check")) \
        + "_layers.csv"
    with open(out, "w", newline="", encoding="utf-8-sig") as f:
        w = csv.writer(f, delimiter=";")
        w.writerow(["layer", "objects", "nested", "result", "suggestion"])
        w.writerows(rows)
    for r in rows:
        if r[3] != "OK":
            print("{:<30} {:>5}  {}".format(r[0], r[1], r[3]))
    print("{} layers, {} off the key, {} fixed. Report: {}".format(
        len(rows), bad, fixed, out))

main()

Lines 10–15, the key as four sets: The whole client guideline lives here. A set is a bag of unique values that Python can search instantly. CONTENT is a regular expression, a pattern for text: one capital letter or dash, then exactly four digits or dashes. EXTRA holds the plain-word layers Zug’s annex 7.1 b also lists for area polygons and stamps. That set is our reading of a two-column table, so check it against your copy.

Lines 17–29, check(): Each test returns early with a reason, and an empty string means the name passed. The order matters. Length comes first because reading position 7 of a 7-character name would fail.

Lines 31–34, suggest(): It tries only cheap fixes, stripping spaces and upper-casing, and proposes a name only if it then passes. It never guesses content.

Lines 36–53, the loop: Per McNeel’s RhinoCommon reference, LayerTable is iterable and its Count includes deleted layers. IsDeleted marks a layer “currently in the Undo buffer” and IsReference one from a referenced document, so the loop skips both. FindByLayer returns the objects on each layer. The rename uses layer.Name plus Modify; an older McNeel forum thread documents a known pitfall with rs.RenameLayer and sub-layer paths. The taken set stops two near-misses from collapsing onto one name. The beginner mistake is to read FullPath as the name. The key is checked against Name, and FullPath appears only in the report. That is why A1E41--E::A1 T88--E fails as “9 characters”.

Lines 54–65, the report: sc.doc.Path gives the .3dm path. An unsaved file falls back to your home folder.

Honest status: the logic ran in plain Python 3.10.11 (python -I), and main() against a stand-in scriptcontext with seven fake layers, not inside Rhino 8. First, check() and suggest():

A1E41--E   OK
ILI3---E   OK
a1e41--e   FAIL agent 'a1' not in list      A1E41--E
A1 E41--E  FAIL 9 characters, needs 8       A1E41--E
A1E41-E    FAIL 7 characters, needs 8
Layer 01   FAIL agent 'La' not in list
Raum       OK
ITI1531T   OK

Then main() on the stand-in model:

--- FIX_NEAR_MISSES = False
Default                            3  7 characters, needs 8
a1m1---e                           4  agent 'a1' not in list
A1E41--E::A1 T88--E                2  9 characters, needs 8
Layer 01                           0  agent 'La' not in list
7 layers, 4 off the key, 0 fixed. Report: ...\Projekt_Musterhaus_layers.csv
--- FIX_NEAR_MISSES = True
Default                            3  7 characters, needs 8
A1M1---E                           4  fixed -> A1M1---E
A1E41--E::A1T88--E                 2  fixed -> A1T88--E
Layer 01                           0  agent 'La' not in list
7 layers, 2 off the key, 2 fixed. Report: ...\Projekt_Musterhaus_layers.csv

“Default” fails on purpose. Nothing personal, Default. Its three objects have to move to a key layer before delivery. Two limits: nested layers are flagged, not flattened, and the script checks names only, so a perfectly keyed layer can still hold the wrong objects. Before trusting it on a live project, run it once on a copy of a real .3dm that includes a nested rename and an empty layer.

Atelier: For a practice delivering to a cantonal client, the layer key stops being a PDF you read at phase close and becomes a gate you run whenever you like. That matters as AI-assisted modelling adds layers faster than anyone names them: a deterministic check keeps the team accountable for what leaves the office. Monday move: put the client’s key into the four sets, run the script on a copy of the live project, and send the CSV to the project lead before the hand-over date is set.

Hack: Measure the problem in objects, not in layers, because four bad layers holding nothing is a different afternoon from one bad layer holding four hundred objects. Paste these lines inside main(), right after the for r in rows print loop. Before you run it, predict the result: on the test model above, expect 9 with the flag off (3 + 4 + 2 + 0) and 3 with it on, because only Default’s objects remain stranded.

stray = sum(r[1] for r in rows
            if r[3] != "OK" and not r[3].startswith("fixed"))
print("{} objects still sit on off-key layers".format(stray))

If your office’s other half lives in Archicad, the same habit of rules written as code is what the PAZ Archicad Python course teaches.

Learn-it:

Open the copy, edit the four sets, and run the check before the client does.

FILED FROM
CO-SIGNERS
PAZ Academy
CONFIDENCE
HIGH
REPRINTS
© PAZ - PARAMETRIC ACADEMY ZURICH · ALL RIGHTS RESERVED

PAZ Kaffi · multidisciplinary editorial, led by PAZ Academy

⚑ REPORT AN ERROR · SUBMIT A CORRECTION
◂ BACK TO FRONT PAGE · PAZ KAFFI

© 2026 PAZ Academy.