Skip to content

Latest commit

 

History

History
54 lines (35 loc) · 4.42 KB

README.md

File metadata and controls

54 lines (35 loc) · 4.42 KB

KiCad plugins for stackup KDL

The PCB editor has three stackup actions:

  • Sync PCB from stackup exports the linked KDL design and updates electrical footprints, pads, and nets. Existing placement, routing, and KiCad board_only footprints are retained. A pad the KDL declares nc is cleared to no net; a pad the KDL does not mention keeps its net. A part placed with hand=#true gets KiCad's Exclude from position files and Exclude from BOM attributes, so the position file and any assembly BOM built from the board, such as a fab plugin's export, leave out what stackup bom marks DNP. The sync removes only attributes it added, so a land that excludes itself (a mounting hole, a test point, a fiducial) keeps them.
  • Repeat arrangement copies selected footprints and connected copper to sibling instances identified by their Stackup Path fields. When no one selected part is the anchor (a block with no part of its own), it asks which part to measure from.
  • Place at anchor pad uses Stackup Anchor, Stackup Spot, Stackup Pours, and Stackup Vias fields already on footprints. KDL anchor=host.PIN on a part exports the host's physical pad to Stackup Anchor; optional spot="dx dy rotation" exports an exact offset. KDL does not emit pours or vias yet.

Install

Install the stackup KDL CLI first. From this checkout, cargo install --path crates/stackup puts it on the shell's PATH. A downloaded executable also works. Then run:

python3 kicad-plugin/install.py

The installer chooses the newest KiCad user directory it finds and copies the plugin into its scripting/plugins/stackup directory. It records the absolute CLI path for KiCad, whose GUI may have a different PATH from the shell. Use --version 10.0 to select a specific KiCad installation, --cli /path/to/stackup to select a CLI, or --target /path/to/scripting/plugins for a custom plugin directory. Run it again with --replace to update an existing copy. It does not replace another installed stackup plugin unless asked.

In KiCad's PCB editor, choose Tools → External Plugins → Refresh Plugins, or restart the editor. The three actions appear under External Plugins and on the toolbar. To change the CLI later, rerun the installer with --replace --cli /path/to/stackup; STACKUP_CLI also overrides the configured path.

For development, a symlink from KiCad's scripting/plugins/stackup to this directory lets Python edits appear after Refresh Plugins. Keep stackup on KiCad's PATH or write its absolute path to stackup-cli.txt in the plugin directory.

Link a board

Put a .stackup_sch file beside the PCB with the same stem. It contains the path to its KDL design, relative to the PCB directory. For example, boards/term-01/term-01.stackup_sch contains:

../../design/term-01/board.kdl

The design can import libraries through its manifest.kdl; the plugin runs the CLI from the PCB directory and uses the normal manifest resolution. A local manifest.local.kdl works as it does at the command line.

To sync a closed board without opening KiCad, use KiCad's bundled Python:

/Applications/KiCad/KiCad.app/Contents/Frameworks/Python.framework/Versions/3.9/bin/python3 \
  kicad-plugin/sync_headless.py boards/term-01/term-01.kicad_pcb

The headless command refuses to write a board open in KiCad. The action plugin works on the editor's open board instead; save the board afterward.

Every sync checks each footprint's 3D bodies. A body a package declares with model is copied into the board's stackup.3dshapes/ and drawn from there. A body a land names that is not on the machine is looked for by file name in the board's stackup.3dshapes/, then in each library's; a library's copy is copied in, and the footprint is pointed at it in the place the land gave it. A footprint whose body is found nowhere is listed in the sync report. The board carries its own copies, so it opens with its bodies on a machine without the libraries.

Anchor chains are placed with hosts before their dependents, both during sync of new footprints and with Place at anchor pad. For example, an inductor anchored to a regulator moves before a capacitor anchored to that inductor. Hosts outside the selection retain their current positions. Cyclic anchor chains and components depending on them stay in place and are reported.

Run the plugin's regression tests with KiCad's bundled Python:

python3 -m unittest discover -s kicad-plugin/tests