Introduction: Automating Eagle Export and Preparing It for Printing.

This is my first instructable and English isn't my primary language so I hope it will be not so bad. There are many instructables for creating boards in Eagle and etching them trough many methods. But this instructable should be just for much faster and automated preparing images of board for printing. I was doing this on GNU/Linux Debian (so don't get confused from different GUI), but should be almost the same for Windows (just you need to edit the pathnames etc...). If it will be hard for somebody doing it on Windows platform I could make another one for Windows.

You need:
Eagle http://www.cadsoft.de/
GIMP (www.gimp.org)
Printer :)

It could be done in some other image editing software, for example in Photoshop. But Photoshop isn't for free and making there automated scripts is too easy and you don't need inscrutables to record action script there.

Step 1: Eagle

When you have your PCB board ready then open your favourite text editor and write there:


DISPLAY ALL
RATSNEST
DISPLAY None
DISPLAY Bottom Pads Vias
EXPORT IMAGE /mnt/slug_common/progs/!8051/!plosaky/!eagle_export.png MONOCHROME 600;
DISPLAY Top Unrouted Dimension tPlace bPlace



You can change the path there (I used this one because I have NSLU2 network drive and exporting directly there makes it accessible from every computer/PDA in my home (and garden as well :) ) ). It's awesome device :)

I saved it in my project folder under name "obraz.scr", you can save it where it is best for you and name it like you want, just keep the ".scr".

Then in Eagle click File -> Script.. Find the location of this script and open it. It will execute the script, it will hide some layers, export it as monochrome PNG image with 600 DPI (you can modify this if you want). You can see the resulting image here. And after exporting showes the layers back. It's great to have it automated because when I'm doing it over and over again, it eats plenty of time and usually I forget to hide some layer and I need it to do it once again. After time it's get very frustrating.

I think when you save this script in Eagles installation directory between others scripts you can execute the script just typing into command line "script obraz;"

Now you can click Options -> Assign and assign the command "script obraz;" with some short-cut, for example Shift+F1. And from this point exporting in Eagle will be super quick.

Step 2: GIMP

Why editing the exported image?

1) My laser printer (and many others) don't do great black colour, when you print it on transparent film and looking trough it, you see that the light can get trough and can make serious troubles in UV process. So I'm doing the same like many others, printing 2 copies (mirrored) and punting them together to make the black colour darker.

When you are printing 2 copies you get next problem, some printers get troubles when there are huge places of black or when there are high contrast lines and are making ghosts. So when you print 2 copies you can see some horizontal / vertical ghost lines on them. So I like to put them not beside, but into opposite corners to avoid all horizontal and vertical ghosts.

2) When you are doing the positive UV process (black should be there where you want keep the cooper) then you need to invert the image because the exported image is usable just for negative UV process. So when you are doing the negative process then you don't need to invert it. And to be honest with you I'm considering to switch to negative one.

What you need in this steep:
Installed and ready to use GIMP www.gimp.org

Open text editor and write there:

(define (script-fu-pcb-filter img)
(gimp-undo-push-group-start img)
(gimp-image-convert-grayscale img)
(gimp-invert 2)
(gimp-image-flip img 1)
(gimp-image-resize img (* (cadr (cddr (gimp-selection-bounds 1))) 2) (* (caddr (cddr (gimp-selection-bounds 1))) 2) 0 0)
(gimp-layer-copy 2 1)
(gimp-image-add-layer img 3 0)
(gimp-layer-new img (cadr (cddr (gimp-selection-bounds 1))) (caddr (cddr (gimp-selection-bounds 1))) 2 "druhy" 100 0)
(gimp-image-add-layer img 4 0)
(gimp-edit-fill 4 2)
(gimp-image-lower-layer-to-bottom img 4)
(gimp-image-merge-down img 2 0)
(gimp-selection-all img)
(gimp-flip 5 0)
(gimp-floating-sel-anchor 6)
(gimp-selection-all img)
(gimp-flip 5 1)
(gimp-floating-sel-anchor 7)
(gimp-flip 3 1)
(gimp-image-merge-down img 3 0)
(gimp-convert-indexed img 0 3 0 FALSE FALSE "a")
(gimp-undo-push-group-end img)
(file-png-save 1 img 8 "/mnt/slug_common/progs/!8051/!plosaky/!eagle_export.png" "/mnt/slug_common/progs/!8051/!plosaky/!eagle_export.png" FALSE 9 FALSE FALSE FALSE TRUE FALSE)

)
(script-fu-register "script-fu-pcb-filter"
"PCB-Filter"
"Gets ready export image from egale ready for print"
"Anton Krug <anton.krug@gmail.com>"
"Anton Krug"
"2009-04-25"
"RGB*, GRAY*, INDEXED*"
SF-IMAGE "Input Image" 0)

(script-fu-menu-register "script-fu-pcb-filter" "<Image>/Image/Eagle/")

You can delete "(gimp-invert 2)" line you don't want to invert the image. And you can modify/delete the line "(file-png-save 1 img 8 "/mnt/slug_common/progs/!8051/!plosaky/!eagle_export.png" "/mnt/slug_common/progs/!8051/!plosaky/!eagle_export.png" FALSE 9 FALSE FALSE FALSE TRUE FALSE)" when you want to save the final image somewhere else, or if you don't want to save it at all.

Then you saves this script in the "Script-Fu" directory of GIMP, on my system it was "/home/fredy/.gimp-2.4/scripts/pcb.scm". On windows try it in installation directory. The you just clicks Xtns -> Script-Fu -> Refresh Scripts, it should load your script too. Then it should be available in Image -> Eagle -> PCB-Filter. Clicking it does the all magic. Sound stupid, but repeating this steep (manualy editing pcb image) too many times it makes you plenty of pain.

I hope this two scripts will save you at least little bit of time and make you developing something much faster.

Comments

author
DrStein99 (author)2016-12-01

Does anyone have a problem printing the image to the correct scale? If so, how did you fix it please?

author
shaun.husain (author)DrStein992017-04-16

Would help to know what OS you're on to give a proper response.

On Ubuntu here I had some issues with the scaling and just the general print driver I installed for a cheapo B/W laser from Canon currently I use an lpr command line to send the image to the printer, despite seeming like a sort of antiquated way of doing things it does work reliably and the options in the manual are actually really nice for printing multiple copies per page doing various scaling and orientation changes etc. Glad to find this tutorial though didn't know you could save the steps in a script and had been manually going back to my favorites to find the steps to get an export. I usually export and print at 1200 dpi so a typical lpr command looks like, lpr -o ppi=1200 Images/pcb.png, where you'd replace Images/pcb.png with whatever actual file you want to print.

author
DrStein99 (author)shaun.husain2017-04-17

I am using Windows. I think I found the command in EAGLE to change the scale that seemed to be defined by the PPI (or DPI resolution). I can't remember what I needed or was doing when I originally posted this comment. I'm playing with printing to a thermal wax printer, to transfer the image to a PCB. It's really fussy with the heat and pressure and I seem to vaporize the wax.

author
KorehS (author)2016-03-06

Hi. I tried to eport the board to png bu i get error:

C:/Users/X/Downloads/Aux Symphony/eagle.scr, Line 5:

Invalid image resolution: Symphony\eagle_export.png

Valid range [dpi]: 1..2400

My script:

DISPLAY ALL

RATSNEST

DISPLAY None

DISPLAY Bottom Pads Vias

EXPORT IMAGE C:\Users\X\Downloads\Aux Symphony\eagle_export.png MONOCHROME 600;

DISPLAY Top Unrouted Dimension tPlace bPlace

What is wrong? Thx

author
Glebanatik made it! (author)2016-03-05

Thank you for the explanation of your script, it was very useful. Now I don't have to hide and display my layers manually when I export image files.

!eagle_export_bad.pngImage 21.png
author
Glebanatik made it! (author)2016-03-05

Thank you for the explanation of your script, it was very useful. Now I don't have to hide and display my layers manually when I export image files.

!eagle_export_bad.pngImage 21.png
author
fuxx (author)2011-05-13

Anton, Gimp scrip doesnt work.
Plug-In 'PCB-Filter' left image undo in inconsistent state, closing open undo groups.
Execution error for 'PCB-Filter':
Error: Procedure execution of gimp-image-convert-grayscale failed on invalid input arguments: Image '!eagle_export_b.png' (5) is already of type 'gray'

On the invert step gives out an error too.

author
truhlik_fredy (author)fuxx2011-05-13

Hmmm, did you altered the output of the eagle?
Because If I remember right then eagle output wasn't GRAY even when

EXPORT IMAGE /mnt/slug_common/progs/!8051/!plosaky/!eagle_export.png MONOCHROME 600;

was set to monochrome.

author
renenijman (author)2011-04-09

Hi,
I get 'unknown command' errors in every line. I'm using EAGLE 5.11.0 on Mac. What could be the problem?
Many thanks!

author
truhlik_fredy (author)renenijman2011-04-09

I don't have Mac :) But try if the commands are working when typed manually. Near by the mouse cursor position coordinates is command line. Click there and type "display none" (without quotes and hit enter). If everything disappears then the commands are working and the problem is somewhere else. So check this first and let me know.

author
gopalyajur (author)2010-08-10

Hello, I have two problems. 1. when I use step 1 and run the script, I do get the image file and png. But, in the final image the the tracks are distorted and gets connected randomly. And in the original CAD Board the tracks change when I use the script. 2. What is the use of second step, its it only for editing or directly creating the PCB image. I use windows and do I have to save the script as "SOMENAME.scm"? And where do I click "Xtns" is it in Gimp. Sorry for my basic questions. Thanks in advance.

author
truhlik_fredy (author)gopalyajur2010-08-11

Did you got it to work?

author
gopalyajur (author)truhlik_fredy2010-08-11

It works and very impressive. Thanks a lot. However, the image is inverted. The tracks are white and the parts to be etched are black. I am not using UV light but, use the chemical etching process. I just had to invert the image and it seems to work.

author
truhlik_fredy (author)gopalyajur2010-08-12

Actually I wanted to have it inverted, because of the etching process and I wanted to have automated every step possible. But it should work for non-inverted process as well. It's in the instructable "You can delete "(gimp-invert 2) " line if you don't want to invert the image." I think you need to register the script again, but it should work. PS: Can you tell me what made the disruptions with routes in the eagle, I just want to know what I have to say when somebody else will have the same problem.

author
gopalyajur (author)truhlik_fredy2010-08-12

I am just using the script you mentioned in step 1 and did not the one you mentioned in step2. Is it possible to change the script in step 1, so that the final image is inverted which is suitable for chemical etching? To be frank its not clear what I can do with step 2. After converting the CAD file to jpg using gimp I just inverted the circuit and got what I needed. The problem I had before is because I did choose just the not bottom layer but, other layers too.

author
truhlik_fredy (author)gopalyajur2010-08-12

Alright when you don't need it, then you don't need it. Just don't convert it to the JPG, it's one of worsts formats what you can use for PCBs, especially when you are making real PCB from the image.

author
truhlik_fredy (author)gopalyajur2010-08-10

Step 1) is for Eagle and it's just hiding some layers so when it will save the resulting image it will be clean from unwanted layers (where are for example descriptions for the chips etc...) Are you sure you routed the whole PCB? Are nets are connected? It will do the same when you do it manually, hide all layers and the show just this 3 Bottom Pads Vias. Or if you have 2 sides on PCB you must make little modification to show Top Pads Vias and save it to different name, and make separate files for top and bottom. The second step is just for adjustment to the image, making it b&w, making second copy and flipping it vertically and moving it to opposite corner. The script name it think is not important and the Xtns button is in the menu next to the File, but it's in the main GIMP window, not in images window.

author
solex (author)2010-05-07

The dpi seems to  be linked to the img size, so the script makes images larger than they should be, what dpi would keep the resolution?

author
solex (author)solex2010-05-07

My mistake, the program I was printing from on my works computer was not respecting the dpi info in the images.

author
truhlik_fredy (author)solex2010-05-07

 It happens from time to time, you know that format keeps dpi, you know that programs are respecting that and then you will find combination of format and program where is some sort of bug and it's not working properly.

author
lunchweek (author)2010-04-29

Is there any way to keep the board size?

author
truhlik_fredy (author)lunchweek2010-04-29

Perhaps we didn't understand us because it always keeps the size, without keeping the size there is no point to make such utility.

author
lunchweek (author)truhlik_fredy2010-04-29

Yeah i just noticed that :) It works like a charm. Thank you!

author
truhlik_fredy (author)lunchweek2010-04-29

 :) I'm happy that it works for you :)

author
abraxas2 (author)2010-04-01

Sorry but I don't understand the path business. If I wanted to store this file in say C:\Electronics\Pic
What would I enter on the path line ?

author
truhlik_fredy (author)abraxas22010-04-02

Perhaps it's misleading because the Eagle client is running on Linux machine.

I suppose that you are using Windows client, then it should be
EXPORT IMAGE C:\Electronic\Pic\MyNameForThePicture.png MONOCHROME 600;

Where the MyNameForThePicture.png should be replaced with yours filename.