Add KiCad IPC API backend (KiCad 9+, incl. v11 nightlies)#555
Conversation
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>
|
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.
|
|
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. |
|
I already posted 3 major things to change above. Start there. |
Summary
KiCad removed the SWIG
pcbnewPython module in development builds (v11 / nightly), so iBOM'sActionPluginno 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
InteractiveHtmlBom/ecad/kicad_ipc.pyIpcApiParser(EcadParser)producing the samepcbdatastructure asPcbnewParser, so the HTML renderer is unchanged.plugin.jsonruntime.type: python, onepcb-scoped action) — restores the toolbar button on v11.ipc_entrypoint.pyrequirements.txtkicad-pythonfor the per-plugin venv KiCad creates.ecad/__init__.pyget_kicad_ipc_parser()factory;kipyimported lazily so nothing changes for SWIG installs or CI.ecad/kicad_extra/__init__.pyimport pcbnewoptional so the package imports under the IPC runtime wherepcbnewis 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
kipyis only imported when the IPC parser is actually requested, soimport InteractiveHtmlBom(and the test suite on KiCad 8/9) never pulls it in.requirements.txt(no reliable Linux wheels) and is instead inherited from system site-packages via KiCad's--system-site-packagesvenv. Without it the plugin still generates headlessly with saved settings.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.