Closed feature request

Feature: configurable layer map for footprint creation (org default layers, incl. Altium typed component layers)

MartyPM · ·closed by Colby Knox

altium-bridge 0.2.111 · adom/core 4.15.3 · Windows 11 (Hydrogen local workspace)

Request

Let a user or an organization define the layer map every footprint verb writes to, so footprints Adom creates land on the org's standard layers instead of fixed mechanical layer numbers.

Today

The layer each graphic goes on is fixed in the bridge and in altium-kicad2altium:

Logical layer Written to today
silkscreen (F.SilkS) Top Overlay
fab / assembly (F.Fab) Mechanical 13 "Fab"
courtyard (F.CrtYd) Mechanical 15 "Courtyard"
comments (Cmts.User) Mechanical 1
solder balls (User.9) Mechanical 9 "Adom.SolderBalls"
3D body Mechanical 1

This affects altium_build_footprint, altium_footprint_from_land_pattern, altium_import_part, the wiki import and altium_add_body. An org whose standard differs has to move every graphic afterwards with altium_edit_footprint.

Our standard (attached: Default Footprint.PcbLib)

The attached library holds one footprint, "Default Footprint" ("Base Footprint with standard layers defined, Designator string, and Centroid placed at the origin"). It uses Altium's typed component layers (MECHKIND), not numbered mechanical layers:

Logical layer Our layer (Altium layer type)
silkscreen Top Overlay
fab / assembly outline Top Assembly (AssemblyTop)
courtyard Top Courtyard (CourtyardTop)
component / body outline Top Component Outline (ComponentOutlineTop)
centroid Top Component Center (ComponentCenterTop), at the origin
designator string Top Designator (DesignatorTop)
dimensions Top Dimensions (DimensionsTop)
3D body Top 3D Body (3DBodyTop)

The bottom pairs (Bottom Assembly, Bottom Courtyard, Bottom 3D Body, ...) and Route Tool Path are also defined.

Proposed shape

  1. A layer map from Adom's logical layers (overlay, fab, courtyard, outline, centroid, designator, dimensions, body3d, comment, balls) to an Altium layer. Address the layer by layer type (MECHKIND) first, then by name, then by number, so it works on AD 24+ typed layers and on older numbered mechanical layers.
  2. Scope: a per-user default, an org-level default (Carbon KV or a file next to the org's library), and a per-call layerMap override.
  3. Seed from a template: e.g. altium_layer_map_from_template {libraryPath, footprint} reads a reference footprint like the attached one and proposes the map from the layers its primitives use.
  4. Start from the template's primitives: optionally copy the template's fixed primitives (the designator string on its layer, the centroid marker) into each new footprint, so every footprint carries them.
  5. Report it: put the layer map used in each footprint verb's reply, so a caller can check it.

Footprints built with the current defaults should not change when no map is set.

Default-Footprint-PcbLib.zip

6 Replies

MartyPM ·

Addendum: start new footprints from the org's Altium template

A layer map alone does not cover how this org works. Altium Designer can be told to start every new PcbLib from a Workspace item:

  • Preference: WorkspaceManager.Workspace Preferences.Template Files
  • Entries: PCBLIB=, PCBPROJECT:PCBLIB= and INTEGRATEDLIBRARY:PCBLIB=, each pointing at a Workspace item (dxp://VaultExplorer:Navigate_URL?...ItemGUID=...&RevisionMode=Last&FileExt=PcbLib).

A library created by the bridge gets the template's layer setup. But altium_import_part / altium_build_footprint build each footprint into a blank footprint, so none of the template footprint's own primitives come across.

Requested

  1. Find the template. Read the PcbLib template from the user's Template Files preference. Altium caches the released file under %ProgramData%\Altium\<edition>\VaultsFileCache\<hash>\Released\.

  2. Start each new footprint as a copy of the template footprint. Then:

    • Keep: the .Designator string with its layer, font, size and justification; the centroid marker; the layer setup; and the Assembly-text style.
    • Remove: the example pad, dimension, example outline, example courtyard and pin-1 dot.
    • Add: the part's own pads, graphics and 3D body.
  3. Derive the layer map from the template. When the template uses typed component layers (MECHKIND), set the map from it automatically, as proposed above.

  4. Keep the designator centred. If the template centres .Designator on the origin, the real designator must stay centred once it is placed.

    Measured on AD 26.10: Center-Center justification on single-line text (MultiLine=False, MultilineTextAutoPosition=5) did not keep a shorter string centred. Swapping .Designator for D1 left the box at x −2.25…−1.34 mm.

    A text frame does keep it centred: MultiLine=True, MultilineTextWidth/MultilineTextHeight set, and the frame centred on the origin with eAutoPos_CenterCenter.

API notes (AD 26.10, DelphiScript through altium_eval)

  • Typed layers: the layer ID is 67108864 + N. The default AddFilter_LayerSet(AllLayers) skips these layers; use AddFilter_IPCB_LayerSet(LayerSetUtils.AllLayers).
  • altium_read_footprint: it doesn't report graphics on typed layers either.
  • Errors: TTFInvertedTextJustification and IsFrame raise runtime errors on text objects.
  • Pipes: a | inside altium_eval text gives "Unterminated string".
Colby Knox ·

Thanks for this, and for the template library and the API notes; they save a lot of digging.

The part about typed layers is a bug on our side: footprint reads that skip Top Assembly, Top Courtyard and the other typed component layers give a wrong answer for anyone who uses them. We're fixing that now and will post here when it ships.

The layer map and starting new footprints from your template would be an option you turn on, so nothing changes for anyone who hasn't set one, as you suggested. We'll follow up here on that once the read fix is out.

Colby Knox marked this in progress ·
Colby Knox · ·edited

The read fix is in altium-bridge 0.2.112, on the insiders channel now; it comes to everyone with the next public release.

  • altium_read_footprint and altium_footprint_primitives now read every layer, the typed component layers included. On your Default Footprint it finds Top Assembly, Top Component Center, Top Component Outline, Top Courtyard and Top Designator, with the .Designator text and its box.
  • Each layer comes back by the name Altium shows. layerDetails gives its id and kind (CourtyardTop, AssemblyTop, DesignatorTop, ...), so a caller can tell a typed layer from a numbered one.
  • courtyardMm now comes from the Top Courtyard layer when the footprint has one.

Thanks for the API notes. For the layer names we used MasterLayerStack.GetMechanicalLayer(N), where N is the id minus 67108864: LayerStack.LayerObject reads only the low byte of the id.

One thing we found while testing: placing or copying one of these footprints onto a board (altium_place_on_pcb, altium_build_board, the library copy verbs) still leaves out its graphics on the typed layers. Only the pads, silkscreen and texts come across. The fix has to put each graphic on the board's layer of the same kind, because a board may number its typed layers differently from the library, so it belongs with the layer map work.

Colby Knox ·

The layer map and template footprints are in altium-bridge 0.2.113, on the insiders channel now. They reach everyone with the next public release.

Your template, in one call:

altium_layer_map {action: "from_template", libraryPath: "<your template .PcbLib>", footprint: "Default Footprint", save: "library", saveTo: "<your organisation's .PcbLib>"}

This reads the footprint and maps each kind of graphic to the typed layer your template uses: fab to AssemblyTop, courtyard to CourtyardTop, centroid to ComponentCenterTop, designator to DesignatorTop, outline to ComponentOutlineTop. It saves that, with the template, as adom-layer-map.json beside the library. That file is your organisation's default: commit it with the library, and every footprint the bridge builds in that folder uses it.

  • Precedence, key by key: a layerMap passed with the call wins, then the folder's file, then a per-user default (altium_layer_map {action: "set", scope: "user"}), then the old fixed layers. With nothing set, footprints come out exactly as before.
  • Layers are named by type, so the map works in any library. A type the library lacks is created as a top/bottom pair. Scripts can only give a type to a pair, and a library or board holds one pair of each kind.
  • From the template, each new footprint keeps the .Designator and the Component Center graphics. The example pad, outline, courtyard, assembly drawing and dimensions are left out. A .Designator centred on the origin gets a centred text frame, as you measured, so the real designator stays centred: on a board, U1 sat centred on its part, on top and after flipping to the bottom.
  • Placing and copying now keep those layers. Placing a footprint on a board, or copying it between libraries, puts each graphic on the destination's layer of the same type, created if missing. A part flipped to the bottom moves to Bottom Assembly, Bottom Courtyard and so on.
  • Every footprint verb's reply includes layerMap: the layer each kind went on and where the setting came from.
  • altium_layer_map {action: "find_template"} reads your Template Files preference and lists the cached Workspace copies. I couldn't test it against a real Workspace template, so if it doesn't point to yours, please paste its reply here.

Tested on Altium Designer Develop with a copy of your Default Footprint. If you try it on a few of your parts, I'd like to hear where it falls short.

Colby Knox ·

altium-bridge 0.2.113 is public now, with the typed-layer reads, the layer map, template footprints and placement keeping the typed layers. Adom Bridge picks it up on its next update check.

We've now also tested it on Altium Designer 26.11.1: the map from your Default Footprint, a footprint built with it, the part placed on a board and flipped to the bottom, and a copy into another library.

Colby Knox ·

Closing this one, since everything in it has been public since altium-bridge 0.2.113: the typed-layer reads, the layer map, template footprints, and placement keeping the typed layers. Thanks again for the template and the API notes.

One part we couldn't test ourselves is altium_layer_map {action: "find_template"} against a real Workspace template, because neither of our machines has one in Template Files. If it doesn't find yours, or anything else falls short, please reopen this issue or open a new one and paste the reply.

Colby Knox closed this ·

Log in to reply.