Skip to main content

Tools for inspecting and DRC'ing PCBs their Gerber files

Project description

GerberTools

Yet another tool for doing stuff with Gerber files. "Stuff" being:

  • rendering to SVGs;
  • rendering to 3D models (Wavefront OBJ format); and
  • (very) basic electrical DRC.

Why? [insert tool here] can already do this.

For as far as I could find, no (open source) tool could do these things from just gerber files (they use their own EDA file format), don't do it detailed enough for my liking, can't be scripted, and/or don't have a way to export the data. It's all kind of a mess. For example...

  • Other tools exist to render Gerber files to SVGs. But they use (comparatively) complex SVG operations to make things work, thus relying on the SVG rendering engine to do most of the work. If you're just viewing the file that's fine; if you're reading them from a script it's not. The SVGs generated by GerberTools only use polygons, making them much easier to read.

  • Most EDA tools nowadays have a 3D viewer built into them. But if they have an exporter at all, the export is limited to the board shape and holes. That's fine when you're doing 3D CAD, but it's nowhere near good enough when you're trying to make somewhat photorealistic renders, like this:

    Example render

    The input file format (i.e. the native format of the EDA tool) can also be an issue, for example when you're crazy enough to procedurally generate a PCB. So is scriptability.

  • DRC has the same "issues" as above: when you only have Gerber files and a netlist, good luck getting any EDA tool to help you.

Ultimately, I built this because I myself needed it. Maybe it'll help someone else as well, maybe not.

How?

The core is written in C++, but wrapped in a (scarcely documented) Python module. This module also includes a basic command-line interface. You can get it the usual way with pip:

pip install gerbertools

Once you have it, you can use the command-line interface using

gerbertools --help

or equivalently, if the above won't work due to path shenanigans,

python -m gerbertools --help

From within Python, you can do something like

import gerbertools
help(gerbertools)
print(gerbertools.get_version())
gerbertools.read('some_pcb').write_svg('some_pcb.svg')

You can also run the tests by running the test_boards.py script in the tests directory. This should give you some basic usage examples, and generates some example output files in tests/output.

Wheels should be available for Windows, MacOS, and Linux using the Python versions active at the time of writing. If you're reading this in N years and there is no wheel for your version, or you have some other reason to build it yourself, it should be fairly straightforward to do so. All dependencies are contained within the repository, so you really just need Python and a C++ compiler. The easiest way to build it is with:

NPROCS=10 pip install -v -e .

where the NPROCS environment variable specifies the maximum amounts of parallel compilation processes to use.

You can also build and install using the usual CMake methods, but then you only get the C++ library that the Python module is based on. So that's really only useful when you want to use the library from C++.

Copyright stuff

The polygon geometry processing is done using the Clipper library, lazily included as source files in this repository. It uses the Boost software license. The same thing goes for Earcut, which uses the ICS license. The relevant license text is at the top of the copied files.

Stuff I add will be licensed under MIT, which I'm more familiar with. Either way, it'll be permissively licensed.

The circuit board files in the test directory have different licenses. They are not distributed with or linked to any build, and I have no affiliation with the makers/owners of those boards.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

gerbertools-0.1.0-cp39-cp39-win_amd64.whl (224.6 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

gerbertools-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (310.1 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

gerbertools-0.1.0-cp39-cp39-macosx_10_14_x86_64.whl (262.2 kB view hashes)

Uploaded CPython 3.9 macOS 10.14+ x86-64

gerbertools-0.1.0-cp38-cp38-win_amd64.whl (227.4 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

gerbertools-0.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (309.9 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

gerbertools-0.1.0-cp38-cp38-macosx_10_14_x86_64.whl (262.2 kB view hashes)

Uploaded CPython 3.8 macOS 10.14+ x86-64

gerbertools-0.1.0-cp37-cp37m-win_amd64.whl (227.6 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

gerbertools-0.1.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (313.9 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

gerbertools-0.1.0-cp37-cp37m-macosx_10_14_x86_64.whl (260.8 kB view hashes)

Uploaded CPython 3.7m macOS 10.14+ x86-64

gerbertools-0.1.0-cp36-cp36m-win_amd64.whl (227.5 kB view hashes)

Uploaded CPython 3.6m Windows x86-64

gerbertools-0.1.0-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (313.7 kB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.17+ x86-64

gerbertools-0.1.0-cp36-cp36m-macosx_10_14_x86_64.whl (260.9 kB view hashes)

Uploaded CPython 3.6m macOS 10.14+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page