Creating Eagle Scripts 101

Eagle scripts are text files with eagle commands. You use them for automating tasks such as changing the width of all the traces on a board, changing board size, or drawing a specific pattern.

Eagle scripts editor

How does eagle scripts work?

To run an eagle script you simply enter “SCRIPT scriptname” (exchange scriptname with the name of the script you want to run) into the Eagle command line.

To be completely honest, I really don’t use scripts much. But I do think they can be really useful, so I am going to try to use them more in the future..

Where to find information about commands?

In a script you can use all the commands that are available to run from the command line. A list of available commands can be found in “Editor Commands” in Eagle’s Help function from the menu.
Eagle help menu

If you click on one of the commands you will get detailed information about how to use that command and which parameters it accepts.
Help for eagle scripts

An example script

Let’s say that we want to create a script to automatically set the board size to 5cm x 5cm. Some of the cheap prototype manufacturers use this size as a standard, so it is convenient to have a script for this.The board size is determined by the board outline which is set by lines in the “20 Dimension” layer. Since these lines does not have any name, we can’t move them with the MOVE command. Therefore I will create a script that creates a new board outline. The old one must be deleted manually before we run the script.

Set grid

First, I need to ensure that we are using a millimeter grid (to be able to set the outline to 50 mm). We use the “GRID” command for this:GRID MM;

Set layer

Then I will select the correct layer. “20 Dimension” is the layers we want, so we can select it by typing:LAYER 20;

Draw lines

Now, all we have to do is to draw four lines that will make up the board outline.
“WIRE 0” means a wire (or line) with a width of 0. Then we define the start and stop point for the line “(0 0) (0 50)”:

WIRE 0 (0 0) (0 50)
WIRE 0 (0 50) (50 50)
WIRE 0 (50 50) (50 0)
WIRE 0 (50 0) (0 0)

Where to find more scripts?

If you want to find scripts made by others, you can go to here.There you will find a bunch of eagle scripts that automate different tasks for you.

Return from Eagle Scripts to PCB Design