GerberJobFile and Project¶
This guide shows how to use GerberJobFile
class and Project
to represent PCB
projects.
GerberJobFile¶
PyGerber provides a GerberJobFile
class to directly handle .gbrjob
files usually
exported alongside Gerber files. You can find
The Gerber Job Format Specification
at www.ucamco.com. Attributes of GerberJobFile
directly map
to values in .gbrjob
file. You can create GerberJobFile
manually by constructing it
out of classes imported from pygerber.gerber.api
or you can load existing .gbrjob
file with from_file()
method.
example.py | |
---|---|
PyGerber Project class¶
Project
class is a container for CompositeView
objects. It is primarily a utility
for grouping CompositeView
objects together, it doesn't really fit into PCB design
workflow but can be really handy to express what should be rendered together while
creating images of PCBs.
Project
has top
, bottom
read-only attributes which containing CompositeView
objects and inner
read-only attribute containing tuple of CompositeView
objects
representing inner layers. Layers in inner
are ordered first to last, L1
at index
0
, Ln
at index n
.
Converting GerberJobFile to Project¶
GerberJobFile
can be converted to Project
object with to_project()
method. This
will automatically read layers from GerberJobFile
and arrange them in Project
object
so they can be rendered.
top:
GerberFile(source='carte_test-F_Cu.gbr', sha256='4b0d219591c6b37af12505f6f5c8846180c4e1bc74f50d5bec0a6ab18ca616a5')
GerberFile(source='carte_test-F_Mask.gbr', sha256='1322445fd9368ac7c9f167a213cbc86651b35752e8bae8c0c3623db319b23e80')
GerberFile(source='carte_test-F_Silkscreen.gbr', sha256='23b6b77cda230055a6f32c8a3719574b2075576ffc444906f129ee88123c984b')
GerberFile(source='carte_test-Edge_Cuts.gbr', sha256='4a6960843955afe271580adb763eae8696251b8c68a295c66af333ad33749a0f')
bottom:
GerberFile(source='carte_test-B_Cu.gbr', sha256='bce8b1dc2e10e0037c9854d834c7e15e8b12934fca21aa8b9345688685ad2eac')
GerberFile(source='carte_test-B_Mask.gbr', sha256='68044ba4c1d4c8579e6d882e295729759f6df5b4906eae925071c5237bc5d71c')
GerberFile(source='carte_test-B_Silkscreen.gbr', sha256='7b64d8e6630afdef5c7bbb39073150d38f822daeb744030ca28f02e37d725e2f')
GerberFile(source='carte_test-Edge_Cuts.gbr', sha256='4a6960843955afe271580adb763eae8696251b8c68a295c66af333ad33749a0f')
Here is image generated by code above:
As you can see, during conversion copper
, soldermask
, legend
and profile
(edge
cuts) files corresponding to top part of PCB were recognized. Be aware that
MaterialStackup
field is currently not taken into account while converting
GerberJobFile
to Project
, so no information about materials or colors is retained.
PCB design disclaimer¶
Gerber files carte_test-*
were generated from KiCad demo project test_xil_95108
.
LICENSE.README in KiCad repository states:
Licensed under CC BY-SA 4.0:
- All the demo files provided in demos/*