Panelizing PCB Stencils

Last year I learned how to build PCBs, and I sweated when I first released my first board (a prototype bluetooth adapter) to production. After spending quite a few sleepless nights inspecting every signal and the routing, I finally had to call it good enough, and send it out to the board house. For the first PCB design, it was individually cut as it was a prototype. When I got the board back, I quickly noticed that I had reversed a couple pins, and it was easily solved with a jumper wire. It goes to show that there’s always going to be some mistakes that slip through, but experience helped me get better. I recently released the Aux Input for production, and it is for sale right now. With this production based board, I knew I wanted to panelize the board, as this would be an efficient way to build the boards. I didn’t know how, so I sent the Gerber files for the individual board to RushPCB.com, and they did a great job panelizing everything, even scoring the boards so they could be easily separated after production. Up to this point, I have been assembling one board at a time, as I didn’t have a solder stencil. I made an individual one with some plastic and an X-acto knife, but this was rather time consuming. After spending a day producing the boards one at at time, I finally had it. I was going to get a stencil which would allow me to do the whole panel at once. However, I only had the CAD files for the individual board, and the stencil manufacturer needed the panelized CAD file. There are several complex tools available that could convert the individual board to a panelized version, but I couldn’t find a single script that could take the simple data from the Gerber file and panelize it. So I made my own simple Python script, and offer it to you if you need something like this. I haven’t tested it on anything more than the solder stencil, so edit away.

#!/usr/bin/env python

# Sam Marmon – Quidzel 2014
#
# Use/modify freely

# Open the individual board, replace board.gtp with filename of your board
file = open(“board.gtp”, “r”)

# Open the panelized board
file2 = open(“panelized.gtp”, “w”)

# Input the pitch of each board
# for example, my board is 1.2″ x .42″
hspace = 120000
vspace = 42000

# Enter the # rows and columns of the
# panelized copies
rows = 2
columns = 2

# Scroll through the Gerber CAD file
for line in file:

# Pad locations seem to start with ‘X’
if line.startswith(‘X’):

# copy the line, and replace the letters with spaces
line2 = line.replace(“Y”, ” “)
line2 = line2.replace(“X”, “”)
line2 = line2.replace(“D”, ” “)

# Split the lines
line3 = line2.split()

# Convert the data points to integers
X = int(line3[0])
Y = int(line3[1])

# Now make copies of the data points
for xnum in range(0,columns):
for ynum in range(0,rows):

# Write out the correct format
file2.write(“X”)
file2.write(repr(X+(xnum*hspace)))
file2.write(“Y”)
file2.write(repr(Y+(ynum*vspace)))
file2.write(“D”)
file2.write(line3[2])
file2.write(“\n”)

else:

# Just write the existing data from the original file
file2.write(line)

# Close the files
file.close()
file2.close()