Creating a diff tool for kicad pcb

Continuing the discussion from Generate gerber files from script:

That’s a great idea which I have been thinking about as well. But requires a canvas implementation for interactively displaying a pcb board. Maybe KiCad’s canvas implementation can be used. I don’t like this idea though. Instead of learning inner workings of kicad, creating one from scratch sounds easier to me (not easy!).

Although web based applications are not my favourite, I’ve been thinking about creating a javascript/svg based canvas for displaying kicad pcb files. That’s because I think such tool would be more useful for collaboration. And collaboration happens on the web nowadays.


If we had arbitrary layers we could pretty easily python up a tool that has all things in both files in the original layers and then all differences in new layers with “Top Copper - Old” kind of names. Merging layers isn’t too hard with the current file format.

You can assume that we have it. Current python API of kicad, provides access to image exporters (gerber, pdf, svg etc). Here is an example script.

But having a reliable method to compare file contents is going to require a good amount of work. For me such a tool should be able report all changes in such form:

  • Module ‘R1’ moved to (10,20) from (0,10)
  • Module ‘R2’ footprint changed to ‘0402’ from ‘0603’
  • Via (Net: GND, Position: 25,36) drill size changed to ‘0.4’ from ‘0.7’
  • etc…

I think I’m asking for too much. Because a tool that is able to report all those changes should be able to detect all possible ‘change types’.

is it possible to plot e.g. Top layer in colored png format by script?

AFAIK there is only vector formats. But I don’t think converting from svg/pdf to png is hard. Imagemagic can do it.

What do you mean by colored?

I was just thinking if it was possible to export pngs for top and bottom layers by python script

that would let me add those images to 3D model of board…
I know I could also create the layers in FreeCAD directly, but that would increase a lot the 3D model itself…

What you want is a texture. I think you will have to do some post processing for this. You can use imagemagic for the job. Actually my pcb2blender project does this for png images exported from eagle. You can find the relevant piece of code here. Note that these commands operate on black&white PNG images.

Thanks for the link…

but I would like to obtain it without external programs… so for the moment I would skip this feature :smile:

What I mean by arbitrary layers is that you could have the common elements on their actual layer and changes on pair of “old” and “new” layers for each effected actual layer such that you could merely select them and do “change layer” all in Kicad in order to merge changes.