Skip to content

Add KiCad IPC API backend (KiCad 9+, incl. v11 nightlies)#555

Open
mikelemo wants to merge 1 commit into
openscopeproject:masterfrom
mikelemo:ipc-api-support
Open

Add KiCad IPC API backend (KiCad 9+, incl. v11 nightlies)#555
mikelemo wants to merge 1 commit into
openscopeproject:masterfrom
mikelemo:ipc-api-support

Conversation

@mikelemo

Copy link
Copy Markdown

Summary

KiCad removed the SWIG pcbnew Python module in development builds (v11 / nightly), so iBOM's ActionPlugin no longer loads there and the toolbar button is gone. This PR adds an alternative backend that talks to KiCad over the IPC API via kicad-python (kipy), running as a separate process. SWIG installs are unaffected.

What's included

File Purpose
InteractiveHtmlBom/ecad/kicad_ipc.py IpcApiParser(EcadParser) producing the same pcbdata structure as PcbnewParser, so the HTML renderer is unchanged.
plugin.json IPC plugin manifest (runtime.type: python, one pcb-scoped action) — restores the toolbar button on v11.
ipc_entrypoint.py Separate-process entry point KiCad launches on button press (wx dialog when available, headless fallback otherwise).
requirements.txt Declares kicad-python for the per-plugin venv KiCad creates.
ecad/__init__.py get_kicad_ipc_parser() factory; kipy imported lazily so nothing changes for SWIG installs or CI.
ecad/kicad_extra/__init__.py Makes import pcbnew optional so the package imports under the IPC runtime where pcbnew is absent.

Validation

Output was diffed against the existing SWIG parser on KiCad 10 using the same board: edges, footprints, pads, tracks, zones, nets and BOM components match to <0.01 mm, byte-identical in most cases. Smoke-tested on a KiCad 11 nightly (10.99) build where SWIG no longer exists — the venv is auto-created with kipy+wx, the toolbar button appears, and generation produces a correct ibom.html.

Notes

  • Existing SWIG path and CI are untouched — kipy is only imported when the IPC parser is actually requested, so import InteractiveHtmlBom (and the test suite on KiCad 8/9) never pulls it in.
  • The interactive dialog needs wxPython; it's deliberately not in requirements.txt (no reliable Linux wheels) and is instead inherited from system site-packages via KiCad's --system-site-packages venv. Without it the plugin still generates headlessly with saved settings.
  • Users must enable Preferences → Plugins → Enable KiCad API server once.

Caveats for review

This is a substantial addition (~1k lines, mostly the new parser) and I'd welcome guidance on whether you'd prefer the IPC backend to live behind a smaller shared abstraction. Happy to adjust.

KiCad removed the SWIG `pcbnew` Python module in development builds
(v11/nightly), so the existing ActionPlugin no longer loads there. This
adds an alternative backend that talks to KiCad over the IPC API via
kicad-python (kipy), running as a separate process.

- ecad/kicad_ipc.py: IpcApiParser(EcadParser) producing the same pcbdata
  structure as PcbnewParser, so the HTML renderer is unchanged. Output was
  diffed against the SWIG parser on KiCad 10 and matches to <0.01mm for
  edges, footprints, pads, tracks, zones, nets and BOM components.
- plugin.json / requirements.txt / ipc_entrypoint.py: IPC plugin manifest,
  per-plugin venv deps, and the separate-process entry point. Puts the
  toolbar button back on v11 where SWIG plugins are unavailable.
- ecad/__init__.py: get_kicad_ipc_parser() factory (kipy imported lazily,
  so nothing changes for SWIG installs / CI).
- ecad/kicad_extra/__init__.py: make `import pcbnew` optional so the
  package imports under the IPC runtime where pcbnew is absent.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@qu1ck

qu1ck commented Jun 13, 2026

Copy link
Copy Markdown
Member

Thanks for taking this on, it looks promising.

Several major things before I go into details and craft a full feature test board to compare the new and old parsers.

  1. Copy existing (old) parser to kicad_swig.py and replace code in kicad.py with new parser. I plan to drop the old one later, assuming ipc api has everything we need.
  2. Make sure the generate_interactive_bom.py script still works with new parser. I think kicad-cli supports server mode (starting with kicad v10.99?) for that purpose.
  3. Add a version check in module top level init so it doesnt register old swig based action for kicad versions supporting ipc api.

@mikelemo

Copy link
Copy Markdown
Author

Hi there glad you like it, I member talking about it with you and the guy who had that yellow orange pic about official IPC support for kicad a few years ago and thanks to claude we can port those changes and enchanse this projects several times faster than big guys like altium Dassault etc... so basically it was a quick sinlge / 2 prompt patch which seem to work with the lastest yesterdays nightly build so far.

Let me know if something is wrong and I'm looking forward for recommandations for porting other useful plugins with that same "SKILL" maybe even in batches so I'm open for suggestions.

@qu1ck

qu1ck commented Jun 13, 2026

Copy link
Copy Markdown
Member

I already posted 3 major things to change above. Start there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants