Posted on

GerbVIO – Python Bulk Import/Export

WARNING! This code is not pretty! This is tourniquet code I wrote to solve a problem with a time budget of about zero seconds. The design pattern used was “fast as hell”. It’s not easy to maintain. Error checking is probably non-existent. This “prototype” has value, though, and there’s no reason it should die so I’m putting it here.

See code at Github

GerbV Fixes Bad Gerbers

For reasons I never had time to understand, poorly formatted Gebers tended to be fixed when ran through GerbV, the open source Gerber viewer. When Gerbers that were not RS-274x complaint were not playing well with the platform, oftentimes, we could mindlessly run them through GerbV and get back to work.

Human Error = Outch!

By “running through Gerbv”, I meant we had to open each Gerber in GerbV and then immediately export it. Doing this with 10-30 Gerber files per PCB it tedious, frustrating, and just begging for a human mistake to happen. If layer17.gbr is overwritten by layer18.gbr by accident, the board would be dead and thousands of dollars would be lost.

Worth The Time Investment?

The time investment to import/export all these files is non-trivial. Deciding to waste 5 minutes on a truly boring solution that may not work wasn’t really in the budget. You had to debate if trying GerbV was even worth your time. Sometimes it was. Sometimes it wasn’t.

Solution

I came up with this script. Right click on a Gerber file in Windows and select Sendto > GerbvIO. Every gerber or drill file in that folder is sent to GerbV, opened, and then exported in the correct format to a new folder. We could immediately use these Gerbers in our system and immediately find out if the Gerbers were complaint.