Generate gerber files from script

I’m trying to write a script that will take a board file and generate a gerber file from it.

Being new to kicad, I find myself in over my head. The only documentation I can find on scripting against kicad is here:

http://ci.kicad.org/job/kicad-doxygen/ws/build/pcbnew/doxygen-python/html/classpcbnew_1_1GERBER__PLOTTER.html

Are there any examples of how to generate a gerber file using python/scripts?

Can’t help, but eager to see what you come up with.

After a lot of searching, found this script which does most of what I’m looking for.

http://github.com/blairbonnett-mirrors/kicad/blob/master/demos/python_scripts_examples/plot_board.py

To automate creating a diff using travis-ci. A script will be run to generate two .png files, and then those png files will be compared to show differences. This must be automatic (without clicking a button in the gui) as to make it easier to project colaborators to see what changes each other is making for every commit.

2 Likes

Not generating gerbers, generating pdf’s and then converting to .png files. Generating a visual diff of a .png is very easy.

I found this blog post that explains exactly what I’m trying to do.

http://www.evilmadscientist.com/2011/improving-open-source-hardware-visual-diffs/

I think it is a good idea, I’ve tried comparing the schematic or pcb files as text, but even small changes can lead to a whole cascade, and it is rather worthless.

The thing that matters is the actual gerber output, so it makes sense to compare that.

Kicad team have gone to great lengths to provide scripting capability - so why the heck not use it? Or are there only certain “approved” uses??

Ok, you don’t get it. That’s fine. I’ll do it my way and you can do it your way. :slight_smile:

I was planning to work on something similar. Do you plan to release your work open source?

When you are at the routing stage, only changes are visual. And looking at the text comparison of two different version of a .kicad_pcb file isn’t really helpful for this.

It would be great if there was tool that can correctly display/highlight changed parts of two different version of a pcb file. But easiest method is the image comparison method as this guy did: http://www.evilmadscientist.com/2011/improving-open-source-hardware-visual-diffs/ or this one: https://github.com/hurik/JGeagle .

Yes, once I get the .png diff files generated, they will be added to a script.
You can follow the progress of the automation here:

I have finished my solution to this problem and incorporated it in this git repo.

It is a python script that takes the current kicad file, plots it as a pdf. It then takes another git commit, and plots that version as a pdf. Both pdf files are then converted to .png files and a compare command generates a diff between them.

Here is what a final product looks like. Blue is before, red is after.

9 Likes

https://github.com/INTI-CMNB/KiBot can generate gerbers and much more from KiCad files, all fully automated (once the config file is setup).

I did not read this 5 year old thread, instead did a little search for “skidl” and it was not mentioned. If you’re interested in scripted PCB’s then I suggest you reasearch this further.