Compare kicad_pcb revisions

Is there any way to compare different revisions of the same design.

There is kicad-diff, which also utilises git, and this sort of works but there are some issues with it. I have looked into generating svg of the designs and then performing an xor but that is failing

I saw something like that some time ago…

leads to:

Here may be something similar for Pcbnew.

If you make a screenshot from different versions and load them as layers or tabs in any graphical program you also have a quick compare method. In astronomy it used to be common to compare photographs of the sky by rapidly switching between photo’s. Any objects that moved between the photographs would start blinking and will draw your attention.

I also did not find the existent tools fit with my workflow, so I tried to build my own.

My path was from .kicad_pcb to .svg via pcbnew python support. Then from .svg to .png via Imagemagick and finally difing (xor-ing) it also via Imagemagick. It worked, but the .svg to .pdf conversion was painfully slow

As it is, for me it is still a problem to solve.

Good job there. How did you build it?

There is this project which I wrote some time ago.

It will generate svg images of the pcb and performs a composite image diff. Supports revisions stored in Git, SVN and Fossil scms.

Thanks for replying.
This is the toolsuite I have been trying to use. It looked like it would fit my needs exactly and the fact it can pull different git revisions was perfect.

I ran into a few issues and a bit of python hacking got over a lot of it but the blocker was the alignment of the resultant layers as part of the HTML - there appears to be an origin alignment issue.
I wanted to spend some time to improve it (pull request).

Short-term, i might go the route @MitjaN sort of alluded to, instead I would used GERBV to convert to PNG then use imagemagick todo the XOR and then merge with the old to show the difference .

Some contribution: it is possible to integrate the special diff tool (in this case the Python algorithm) into Git for specific file extension by modifying the content of .gitconfig and .gitattributes files.

Some software as LabVIEW use this specific approach to solve the merge conflicts.

The ‘plot’ function from pcbnew is zero referenced to the canvas origin. The individual plots are based on this zero origin so if you move the whole board but don’t edit any of the contents, it will still show as a (very large) difference even though the two images are superimposable.This is a non-trivial problem to solve - which bit of the board is the best common point of reference to minimise the difference set between two designs. If you don’t move the board outline and make regular commits, the strategy used works but I fully accept that it isn’t ideal. I did start to explore afine matrix transformations to translate board files but I am neither a skilled enough programmer nor mathematician to be able to develop this.

Besides which, I am not convinced that a graphic approach is the best solution. A better strategy might be to use the semantic version of the board file and diff between the individual tracks/pads etc. This requires diffing the two designs and reverse parsing the s-expression to extract the parent feature. back through the tree. Again, this is still not tolerant of board translation/rotation. It also requires a ‘quiet’ and efficient diff. I think Kicad has improved significantly but until fairly recently, KiCad diffs were ‘noisy’ - whole chunks of the pcbnew file were moved around between commits. Although this had no visual effect on the board rendering in KiCad, it made it next to impossible to extract a true, minimal diff between files. I know that a lot of work has gone into improving this recently. I think @pointhi was working on a version comparison strategy based on this approach but not sure if there has been any progress.

Just to add some clarification: my aux origin and board outline & position were set almost immediately. A few edge cut changes early on as I was aligning multiple cards etc.

Fast forward a couple of months the differences that now should be seen are purely part placement and tracing but what is occuring is the visual diff is providing gross misalignment.

Whether kicad orign (0,0) or aux origin is used shouldn’t matter for the datasets being considered here. What I have noticed is different executions will provide different levels of alignment.

This toolsuite looks ideal for what I need, just a few quirks to work around. I am more than happy to figure this out I just had a short-term need against a medium term goal.

I’ll provide a screenshot shortly. I am on a Windows machine and it outright doesn’t work for Windows (silly py27) but works fine on my home desktop

I am on Windows and I am quite fond of TortoiseGit. So I wanted a tool I could use with Tortoisegit, and the tool would only open the image viewer showing the diff. Other tools generating .html were a bit too much for my workflow.

First issue was how to generate proper .svg files. Here I based my code upon Scott Bezek’s work

Then I used inkscape to trim the svg page size down to edge cuts

"C:\Program Files\Inkscape\" -D -l="%~d1%~p1%~n1-B_Cu-alt.svg" "%~d1%~p1%~n1-B_Cu.svg"

Then I converted the .svg to .jpg˛using imagemagick

convert -size 2000 "%~d1%~p1%~n1-B_Cu-alt.svg" "%~d1%~p1%~n1-B_Cu.gif"

Generate diff

composite -stereo 0 "%~d1%~p1%~n1-F_Cu.gif" "%~d1%~p1%~n2-F_Cu.gif" "%~d1%~p1%~n1-%~n2-diff-F_Cu.png"

and finally I merged four diffs (F.Silk, B.Silk, F.Cu, B.Cu) into one picture using tte montage command

As said. It works, but painfully slow. And given all the dependencies (Imagemagick, inkscape) I didn’t publish my findings as the system is not trivial to set up.

While we’re at it, Windell Oskay also wrote something on the topic (it is a bit old (2011) though)

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