Is it possible to try the new python API?

If someone wants to automate tasks with scripting in the latest stable KiCad, the only option (as far as I know) is to use the python library “pcbnew” and execute the scripts in the scripting console in the PCB layout editor.

I just saw a video on youtube with Jon Evans talking about a newly developed python API that will be part of KiCad 6. This sounds really great.

My question is: Is it possible to try out the new python API by installing the KiCad nightly build?

I would like to learn how to automate things in KiCad and would rather learn about the new API rather than learning about the old pcbnew lib.

BR abaldur

New api has not been merged yet. Quite a few people are interested in that actually.

Not yet. ATM we don’t know more than what has been said in Post-v5 new features and development news (unless someone here has some insider knowledge).

This is not completely accurate: the API can be used also as a normal python library from standalone python. But it’s the same API nevertheless. And the same is true for the new API: it can be used from inside KiCad and from outside.

Thanks for the reply.

I didn’t know that the pcbnew python library could be used as a normal python library. In all the videos and blog posts I have seen so far it has been executed from inside the KiCad scripting console and therefore thought it was somehow strongly tied to the PCB layout editor.

One of the reasons I’m interested in the new python API is that it should be targeting all the KiCad modules, not just the PCB layout editor. Right now, I’m interested creating some scripts that can make my life easier when creating footprints inside the footprint editor. But I guess I can use pcbnew for that as well?

Do you think it’s worth investing time in learning the pcbnew library, or would you wait until the python API is released? Would I be able to learn the new python API quicker if I already know about the pcbnew library?

I don’t really know what the new library has, but I expect the overlapping parts (most importantly handling board items, including footprints) to be fairly similar than the current API. Learning it now won’t be wasted if I’m right. After all you need to do the same things: iterate through board items, create new items, get and set their properties, move, rotate etc. Because the underlying file format / data structure is the same, they can’t be totally different, and the purpose of the new API isn’t to be totally different, either, but to be more stable and easier to use than the current one which has been changing constantly. Also the plan has been to not hide the old (current) lower level API but to keep it available if you need something from there which doesn’t exist in the new API.

But there are APIs for other things, too: creating output files, for example, which is good for automation. I know practically nothing about those.

1 Like

It’s only going to be pcbnew and eeschema for v6.

Look into footprint wizard scripts, they are already a thing separate from pcbnew plugins but also python based.

I just started a new topic on how to create SnapEDA footprints directly from my KiCad designs.
I use KiCad 5.99 Nightly. I realise that I need the new version 6 API if I need to create a tool to upload to SnapEDA (they require uploads Eagle LBR format, or you have to craete all the different versions for different EDA packages yourself) Export your own KiCad design as footprints to SnapEDA

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.