by adom
Let an AI (Claude, ChatGPT, Codex or any agent) run Altium Designer for you: create symbols and footprints, place parts (also from Altium 365), wire and annotate schematics, Update PCB, set the stack-up and rules, route, pour copper, add mounting holes and stitching vias, run ERC and DRC, and make Gerbers, BOMs and STEP. Free in Hydrogen; bring your own AI and Altium licence.
Footprint/layer-map verbs fill PcbLibs with 1024 mechanical layers (GetMechanicalLayer loops create layers)
altium-bridge 0.2.118 (agent script AdomAgent_de5bd2abe4.pas) · Altium Designer Develop 26.x (AD 26.10.1.5 installed alongside) · Windows 11 (Hydrogen local workspace)
What happens
PcbLibs that the bridge's footprint / layer-map verbs have worked on end up with all 1024 mechanical layers defined. Once such a library is open, Altium lists Mechanical 1..1024 in Preferences » PCB Editor » Layer Colors. A fresh Altium instance that has not loaded the library shows only Mechanical 1..16, as normal.
Layer records counted in the saved files (LAYER_V8_<n>NAME= records, highest MECHANICAL<n>):
| PcbLib | layer records | highest mechanical layer |
|---|---|---|
| Organisation footprint template (never touched by the bridge) | 71 | 66 |
Library built with altium_layer_map + altium_footprint_from_land_pattern / altium_edit_footprint (2026-12-01) |
1048 | 1024 |
| Second library, same verbs (2026-12-02) | 1086 | 1024 |
Likely cause
In Altium, looking a mechanical layer up by its number creates it in the open document, and the next save keeps it. The agent script loops over every possible mechanical layer:
MechNoOfKind:For N := 1 To 1024 Do ... Board.MasterLayerStack.GetMechanicalLayer(N)MechNoNamed:For N := 1 To 1024 Do ... GetMechanicalLayer(N)FreeMechNo:For N := 17 To 1024 Do ... GetMechanicalLayer(N)
(around lines 1700-1760 of AdomAgent_de5bd2abe4.pas in %LOCALAPPDATA%\Adom Bridge\bridges-cache\altium\agent\ADDevelop\).
Confirmation from our own tooling: a verify script of ours looped LayerObject_V7(LayerUtils.MechanicalLayer(i)) for i = 1..128 (read-only intent). After it ran and the library was saved, a clean 71-record library had 152 records with Mechanical 67..128 added. Removing that loop stopped it.
Why it matters
Probably the cause of Altium hangs we saw. Attaching a STEP to a footprint (ComponentBody.ModelFactory_FromFilename + AddPCBObject) hung Altium twice in a 1024-layer library (window "not responding", had to be killed). The same attach on the same footprint, in a library recreated from the template (71 layer records), completed immediately.
Suggested fix
- Never look mechanical layers up by number in a loop. Iterate only the layers the document already has, or keep a cache of known layers.
- Find a typed layer by kind / name among existing layers only; when a new layer is needed, create exactly one.
- Possibly add a guard to the verbs: report (and refuse to save) when a library's mechanical layer count jumps.
Repro (expected; inferred from the layer counts and the code above, not re-run in isolation)
- Copy a template PcbLib with few mechanical layers; count
LAYER_V8_<n>NAME=records (e.g. 71). - Run
altium_layer_map {action:'from_template', ...}andaltium_footprint_from_land_patternon it; save. - Count again: 1024 mechanical layers.
Related: #43 (the footprint verbs also create Mechanical 1 and 9 "Adom.SolderBalls" when nothing is drawn on them).