I am using Ubuntu but I am sure those or similar packages are also available in other distros/package managers:
apt-get install python
apt-get install python-simpleparse
apt-get install gerbv
We created our own fork of gerbmerge that adds some SMD stencil related features:
We want to fill an SMD stencil with as many PCBs to make optimal use of the space.
The top and bottom cream layers together with the board outlines are exported through Eagle as CAM job and then processed with gerbmerge and manual absolute placement to create one combined gerber file that can be sent to an SMD stencil manufacturer.
Eagle CAM Job to create required gerber files (plus a few others that we don't need for the stencils):
Note: Make sure the bottom cream side has the "mirror" checkbox checked when running the job.
The three essential files/layers we need are:
We want to merge 3 gerber files here for demonstration purposes (later we want to fill one stencil with as many boards as possible to not waste space): The general stencil frame with holes for fixing the stencil with screws and one PCB with top and bottom sides.
create an empty file called empty (gerbmerge requires a drill file or will throw an error - but is happy with an empty one)
create job.cfg with the following content (file names are left in for demonstration purpose):
[DEFAULT] projdir = . [Options] AllowMissingLayers = 1 PanelWidth = 12.9 PanelHeight = 18.5 [DummyTop] BoardOutline=axiom_beta_interface_dummy_v0.12.dimensions.ger Drills=empty *topcopper=axiom_beta_interface_dummy_v0.12.tcream.ger [DummyBottom] BoardOutline=axiom_beta_interface_dummy_v0.12.dimensions.ger Drills=empty *topcopper=axiom_beta_interface_dummy_v0.12.bcream.ger [StencilTemplate] BoardOutline=stencil02.gtp Drills=empty *topcopper=stencil02.gtp
Create a file called stencilplacement.txt with the following content:
StencilTemplate 0.500 0.500 DummyBottom 5.000 2.000 DummyTop 2.000 2.000
For rotating certain boards use a syntax like this:
StencilTemplate*rotated 0.500 0.500 DummyBottom*rotated90 5.000 2.000 DummyTop*rotated180 2.000 2.000 DummyTop2*rotated270 2.000 2.000
Our gerbmerge fork also takes additional parameters together with the coordinates:
To define the origin of each board:
l = left c = center r = right
b = bottom c = center t = top
Another letter can follow to define the relative position from the panel:
L = left C = center R = right
l = left obeying insets c = left obeying insets r = left obeying insets
So for example this line places the board exactly in the center of the panel:
board 0cC 0cC
The gerbmerge automatically creates boundary rectangles of each board to simplificy placement. As the StencilTemplate has no BoardOutline the first hole on it will be moved right at the original of the output gerber file so we have to manually offset the stencil template by half an inch in X and Y axis.
python gerbmerge.py --place-file=stencilplacement.txt job.cfg
gerbmerge will ask you to agree to its warranty notice and output a few lines with board dimensions and the output files it created.
For our config:
../gerbmerge.git/gerbmerge/gerbmerge.py -s --no-trim-gerber --place-file=placement_0001.txt job_0001.cfg
Look at the resulting files in the gerber file viewer gerbv: