Skip to content

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

Open
mikelemo wants to merge 2 commits into
openscopeproject:masterfrom
mikelemo:ipc-api-support
Open

Add KiCad IPC API backend (KiCad 9+, incl. v11 nightlies)#555
mikelemo wants to merge 2 commits 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.

- Move legacy SWIG parser (PcbnewParser + the ActionPlugin) to
  ecad/kicad_swig.py and promote the IPC API parser into ecad/kicad.py
  so the IPC backend is the default going forward.
- generate_interactive_bom.py: route .kicad_pcb through the IPC parser
  when an API server context is present (KICAD_API_SOCKET), otherwise
  fall back to the SWIG parser which loads the board file from disk.
- Skip registering the legacy SWIG ActionPlugin on KiCad 9+ (where the
  IPC plugin manifest provides the iBOM action) to avoid a duplicate
  toolbar button.

I hate work, and may the Claude be with you.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@qu1ck

qu1ck commented Jun 16, 2026

Copy link
Copy Markdown
Member

I will need to put together a test suite of boards to validate new parser, I dont think eyeballing it with a couple of boards will cut it. Give me a few days.

@mikelemo

Copy link
Copy Markdown
Author

I will need to put together a test suite of boards to validate new parser, I dont think eyeballing it with a couple of boards will cut it. Give me a few days.

Sure thing no hurry, for me this seem to work but still haven't tested it on more than a couple of boards as well.

@qu1ck

qu1ck commented Jun 30, 2026

Copy link
Copy Markdown
Member

Just an update to show I havent forgotten about this, I have a whole bunch of test cases prepared already but need more for full coverage.

 ~  ls tests/kicad_integration/pcbs/*.kicad_pcb
tests/kicad_integration/pcbs/board_outline_arc.kicad_pcb
tests/kicad_integration/pcbs/board_outline_bezier.kicad_pcb
tests/kicad_integration/pcbs/board_outline_circle.kicad_pcb
tests/kicad_integration/pcbs/board_outline_large_arc.kicad_pcb
tests/kicad_integration/pcbs/board_outline_polygon.kicad_pcb
tests/kicad_integration/pcbs/board_outline_rect.kicad_pcb
tests/kicad_integration/pcbs/board_outline_simple.kicad_pcb
tests/kicad_integration/pcbs/board_outline_widths.kicad_pcb
tests/kicad_integration/pcbs/fab_b.kicad_pcb
tests/kicad_integration/pcbs/fab_f.kicad_pcb
tests/kicad_integration/pcbs/footprint_complex_edge_cut.kicad_pcb
tests/kicad_integration/pcbs/footprint_complex.kicad_pcb
tests/kicad_integration/pcbs/footprint_complex_th.kicad_pcb
tests/kicad_integration/pcbs/footprints_distinct.kicad_pcb
tests/kicad_integration/pcbs/footprints_groups.kicad_pcb
tests/kicad_integration/pcbs/footprint_simple.kicad_pcb
tests/kicad_integration/pcbs/footprint_simple_rotated_flipped.kicad_pcb
tests/kicad_integration/pcbs/footprint_simple_rotated.kicad_pcb
tests/kicad_integration/pcbs/footprint_to-92.kicad_pcb
tests/kicad_integration/pcbs/pad_npth.kicad_pcb
tests/kicad_integration/pcbs/pad_smt_chamfered_roundrect.kicad_pcb
tests/kicad_integration/pcbs/pad_smt_chamfrect.kicad_pcb
tests/kicad_integration/pcbs/pad_smt.kicad_pcb
tests/kicad_integration/pcbs/pad_smt_net.kicad_pcb
tests/kicad_integration/pcbs/pad_smt_oblong.kicad_pcb
tests/kicad_integration/pcbs/pad_smt_polygon.kicad_pcb
tests/kicad_integration/pcbs/pad_smt_round.kicad_pcb
tests/kicad_integration/pcbs/pad_smt_roundrect.kicad_pcb
tests/kicad_integration/pcbs/pad_smt_trapezoid.kicad_pcb
tests/kicad_integration/pcbs/pad_th_custom_stack_connected.kicad_pcb
tests/kicad_integration/pcbs/pad_th_custom_stack.kicad_pcb
tests/kicad_integration/pcbs/pad_th_fb_custom_stack.kicad_pcb
tests/kicad_integration/pcbs/pad_th.kicad_pcb
tests/kicad_integration/pcbs/pad_th_oblong_hole.kicad_pcb
tests/kicad_integration/pcbs/pad_th_offset_hole.kicad_pcb
tests/kicad_integration/pcbs/silkscreen_b.kicad_pcb
tests/kicad_integration/pcbs/silkscreen_circle_filled.kicad_pcb
tests/kicad_integration/pcbs/silkscreen_circle.kicad_pcb
tests/kicad_integration/pcbs/silkscreen_f.kicad_pcb
tests/kicad_integration/pcbs/silkscreen_polygon_filled.kicad_pcb
tests/kicad_integration/pcbs/silkscreen_polygon.kicad_pcb
tests/kicad_integration/pcbs/silkscreen_text_flipped.kicad_pcb
tests/kicad_integration/pcbs/silkscreen_text.kicad_pcb
tests/kicad_integration/pcbs/silkscreen_text_mirrored.kicad_pcb
tests/kicad_integration/pcbs/silkscreen_text_rotated.kicad_pcb
tests/kicad_integration/pcbs/silkscreen_text_ttf.kicad_pcb
tests/kicad_integration/pcbs/silkscreen_text_unicode.kicad_pcb
tests/kicad_integration/pcbs/tracks_arc.kicad_pcb
tests/kicad_integration/pcbs/tracks_b.kicad_pcb
tests/kicad_integration/pcbs/tracks_f.kicad_pcb
tests/kicad_integration/pcbs/tracks_nets.kicad_pcb
tests/kicad_integration/pcbs/tracks_via_net.kicad_pcb
tests/kicad_integration/pcbs/tracks_widths.kicad_pcb
tests/kicad_integration/pcbs/zone_b.kicad_pcb
tests/kicad_integration/pcbs/zone_both.kicad_pcb
tests/kicad_integration/pcbs/zone_f.kicad_pcb
tests/kicad_integration/pcbs/zone_nets.kicad_pcb

@mikelemo

mikelemo commented Jul 2, 2026

Copy link
Copy Markdown
Author

Testing shmesting... enough with the buerocracy people are waiting push it already, it's already proven to do the job and back then that was the only solution, just integrate it in a way kicad expects for package downloads through the UI. for the cases that won't work you'll get people feedbacking you doing the work for free(like a bug report -> patch exchange)...

@qu1ck

qu1ck commented Jul 2, 2026

Copy link
Copy Markdown
Member

Yeah, that'll be a hard pass from me.
It's not proven until it's tested. My trust in vibecoding without triple checking the output is non existant.

@mikelemo

mikelemo commented Jul 3, 2026

Copy link
Copy Markdown
Author

but it's significantly better than the nothing that is being offered right now for that version and it basically generates the iboms for 2 projects tested so far so what's the deal? kicad and freecad are shitty softwares with tons of bugs and things that don't work or are expected to work but cause the app to crash all to this day. that's not something that goes to run your Bank I think community feedback and testing of other people even those who don't understand the codebase is one of the easiest fastest and in some cases most practical way to test software (not completely advocate those but most of big tech companies work that way sometimes releasing things that are too broken to be practical...) Claude got quite good and accurate from the last 3 years, give it a try, don't be a Boomer.

@qu1ck

qu1ck commented Jul 3, 2026

Copy link
Copy Markdown
Member

I use llms, I'm not averse to them. But "I ran it on two projects, it didnt throw an error and it generated something that looks right" means it has basically 0 testing.

Over the years there were a lot of bug reports for corner cases to get the rendering right, I'm not about to push some half-baked ai slop out on users and go through same issues again. Especially since I already have a good working code, it's output can be used as reference to check new implementation, which is exactly what I'm doing now. Or trying to find time to finish doing, to be exact.

KiCad 11 will not be released until 2027, it's ok if ibom doesnt work on nightly.

@mikelemo

mikelemo commented Jul 4, 2026

Copy link
Copy Markdown
Author

sounds harsh, that's an OS repo who the heck pays you to do that? whatever let me know if you find anything critical I'll solve it with some swearing :D

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