rocketnumbernine

Andrew's Project Blog: Hardware, Software, Stuff I find Interesting

I was fed up with creating gerber files through the Eagle GUI and bundling them up manually before sending to get manufactured so created a shell script. It's not rocket science but I couldn't find that much help on the internet so the following may help others figure it out faster - have briefly tested in Eagle 6.0.0 and appears to work the same as 5.0.

Eagle gerb274x cam file screen

Gerber files, for example the top copper .cmp gerber file (created using the gerb274x cam file in Eagle pictured above), can be created from the shell using the following:

eagle -X -dGERBER_RS274X -oboard.cmp board.brd Top Pads Vias

Where Top, Pads, and Vias etc. are the eagle layers to be exported from board.brd to the board.cmp. This has to be repeated for each gerber file (silkscreen, solder mask etc.) required. "eagle -?" will display its command line options and you can assign offsets and mirror the output if you wish. If you're on windows "eaglecon.exe" should be used so it doesn't detach from the console.

Excellon drill files can be created using the following:

eagle -X -dEXCELLON -oboard.drd board.brd Drills Holes

If the board maker needs a (drl) rack file (you "run drillcfg" from within Eagle), the following lines of sed will produce the same contents from the dri file - I can't figure out how to run drillcfg without prompts without rewriting it. ). Note this only works as long as you don't adjust the drill sizes when prompted by drillcfg (which you probably shouldn't anyway):

1
2
cat board.dri | sed -e 's/ *\(T[0-9][0-9]\) *\([0-9.]*..\).*/\1 \2/' | \
    grep -e "^T[0-9][0-9]" > board.drl

Finally, here's my script to create a zip of everything ready to send. Obviously use at your own risk - try creating through both the GUI and command line method and compare the output files to see what the differences are until you've tweaked it to your requirements.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#! /bin/bash
# andrew@rocketnumbernine.com - Use freely, for whatever, at your own risk.

EAGLE="/Applications/EAGLE/EAGLE.app/Contents/MacOS/EAGLE"

if [ $# -lt 1 ] ; then
        echo "usage $0 <path-to-board> [output-dir-and-file-prefix]"
        echo " e.g:  $0 my_boards/boardx.brd gerbers/board"
        echo "  will create gerber files with eagle in a directory called gerbers"
        echo "  and bundle into gerbers.zip"
        exit 1
fi

board="$1"
outputfile=${2:-"$(dirname $board)/$(basename $board .brd)"}
outputdir=$(dirname ${outputfile})

if [ ! -d ${outputdir} ]; then
        mkdir -p ${outputdir}
fi
set -e

# create top copper (cmp), bottom copper (sol), top solder mask (stc), bottom solder mask (sts), {top} silkscreen (plc)
${EAGLE} -X -dGERBER_RS274X -o${outputfile}.cmp ${board} Top Pads Vias
${EAGLE} -X -dGERBER_RS274X -o${outputfile}.sol ${board} Bottom Pads Vias
${EAGLE} -X -dGERBER_RS274X -o${outputfile}.stc ${board} tStop
${EAGLE} -X -dGERBER_RS274X -o${outputfile}.sts ${board} bStop
${EAGLE} -X -dGERBER_RS274X -o${outputfile}.plc ${board} Dimension tPlace

# create drill files
${EAGLE} -X -dEXCELLON -o${outputfile}.drd ${board} Drills Holes
# get drills used from dri file and create drl rack file 
# (like running drillcfg.ulp: ${EAGLE} -N- -C'RUN drillcfg.ulp; QUIT;' -o${outputfile} ${board}
cat ${outputfile}.dri | sed -e 's/ *\(T[0-9][0-9]\) *\([0-9.]*..\).*/\1 \2/' | grep -e "^T[0-9][0-9]" > ${outputfile}.drl

zip -r ${outputdir}.zip ${outputdir}

It looks like your browser doesn't support javascript so comments won't work

Tags/Categories: howto, pcb, eagle

Contact
andrew @ rocketnumbernine.com
Feed-icon16x16 Subscribe to RSS
phatIO
Checkout phatIO an IO device that looks like a USB filesystem

Set a pin to 5V by saving "1" to its control file, set it back to 0V by saving "0".
Control LCD and LED displays by writing the data to display to a file.
Communicate with TWI, and SPI and other devices by writing data to a file.
Videos, reference and more at phatIO
Share with others: