Automating Eagle Export and Preparing It for Printing.

46,196

39

26

Posted

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.

2 People Made This Project!

Recommendations

  • Epilog Challenge 9

    Epilog Challenge 9
  • Sew Warm Contest 2018

    Sew Warm Contest 2018
  • Paper Contest 2018

    Paper Contest 2018
user

We have a be nice policy.
Please be positive and constructive.

Tips

Questions

24 Comments

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

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.

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.

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

user

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.

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.

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!

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.

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.