Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experimental support for KiCad 9 kicad-python #128

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

mairas
Copy link
Contributor

@mairas mairas commented Feb 7, 2025

Hi,

KiBuzzard was always crashing on KiCad 9 nightlies when I tried to edit any created labels. I assumed it was a KiBuzzard issue and instead of trying to debug the SWIG interface, I decided to try the new IPC API and the kicad-python bindings. Turns out, I was out for an adventure.

This PR, which should NOT be merged to main as-is, contains my experimental KiBuzzard version using kicad-python. It somewhat works, but since you can't initiate a clipboard paste or an interactive place operation from the new API, I just copy the footprint to the clipboard instead. For updates, the old footprint is removed but you still need to initiate pasting manually to replace it with the updated one.

Here are rough steps to get the PR branch version working.

Prerequisites: KiCad 9 nightly (I don't think -rc2 would work but not sure about that).

Clone kicad-python main branch and build into a wheel (poetry build).

Clone this PR to ${KICAD_DOCUMENTS_HOME}/9.0/plugins. Replace the kicad-python path in requirements.txt with the wheel you created (should be in the dist directory of kicad-python sources.

To see what's going on, you might want to enable tracing for the API:

export KICAD_ALLOC_CONSOLE=1
export KICAD_ENABLE_WXTRACE=1
export WXTRACE=KICAD_API

Then launch KiCad from the command line. On Linux the process is obvious, on MacOS, you need to run the binary inside the .app directory, for example:

/Applications/KiCad\ 2025-02-06/KiCad.app/Contents/MacOS/kicad

Open a project and start PCB Editor. With a bit of luck, you'll have a KiBuzzard icon on the toolbar. Click on it. KiBuzzard will start as a separate process. On a Mac, the KiBuzzard window is always behind the PCB Editor window and isn't visible in Mission Control, but you can switch to it via the Dock. (To make this more bearable, I created a Hammerspoon snippet that raises the window automagically when it's created.))

At this point, you should have a plain old KiBuzzard dialog window. Create your label and click OK. This will close the dialog. You will need to paste the created label footprint manually on the PCB.

Editing works as before, almost: select a KiBuzzard label and click on the icon. KiBuzzard will open (behind the main window) and will have the label data preloaded. Make your changes and press OK. The old label is removed and the new one is placed on the clipboard. You will need to paste it yourself!

As of today, the PCB Editor will tend to crash soon after any footprint is pasted, so whenever you make an update, save, close and restart PCB Editor. If you don't, KiCad will do this for you, taking also the schematic editor down... A fix has been committed, so in the next nightly (after 2025-02-26), the issue might be fixed.

NOTE: My problems with the stock KiBuzzard are likely due to the same issue linked in the previous paragraph. Assuming this is the case, the stock version should work just fine and there is no reason to actually use this PR version. However, if kicad-python improves over time, my dabblings could be used as a basis for an updated KiBuzzard.

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.

1 participant