Adding a default stencil layer in Eagle

After all the work setting up a stencil and adding a layer to produce the Stencil Gerber in the last post, I wondered if there was a way to automate the process a little more. What was needed was a default Stencil layer to appear in Eagle when a new board was made. This is achieved by editing the eagle.scr file within the Eagle directory structure. Make sure you make a backup copy of the file before you edit it. I copied mine and renamed the copy BAK_eagle.scr_BAK so that it would be a simple step to rename back if I made a mistake and Eagle no longer started.

Edit the file with a plain text editor. On Windows, notepad would be a good choice because it doesn’t add formatting. Avoid Wordpad, Word and other editors that add invisible formatting to the text.

Open the file located in your \Eagle\scr\ directory called eagle.scr This is the script that is run when a new schematic, board or library part is defined. Find the BRD: section which should be at the top of the file. After the current settings and before the SCH: heading, add ‘LAYER 255 Stencil’. This will define a new layer numbered 255 called ‘Stencil’ every time you create a new board. Save the file and start Eagle normally.

Start Eagle and open any board you have made before. If you haven’t previously made a board, click on FILE-NEW-BOARD If you now open the layers dialog by clicking on the layers icon in the left hand toolbar or clicking VIEW-Display/hide layers, you will see there is a layer at the bottom of the list called Stencil. Any board that didn’t have the new layer before the eagle.scr edit was made will need to be saved before the next step.

To add it to a CAM file or create one fresh, click on the CAM icon or FILE-CAM Processor. You can add it to your normal CAM file too, click on FILE-OPEN-JOB. Click on ADD to add a section. In either case, name the section Stencil. Set the device for GERBER_RS274X. Set the filename to %N_stencil.gbr This will use your projects filename and append ‘_stencil.gbr’ to it. Make sure pos. Coord and Optmize are checked. Then go into the layer list and make sure that only 31 tCream and 255 Stencil are highlighted. Then you can save the job for later use.

Once you have set up the above, you can then call on the section in the job after you have designed a board and it will output a gerber file combining the solder paste layers along with your new stencil layer. Of course, if the job already creates standard gerbers, the stencil gerber will now be added. I would recommend that you preview the file before you send it to your fabricator and perhaps edit to taste as I documented in my last post ‘Designing a Solder Stencil with Eagle‘.

Please note: Editing configuration files can stop applications from working. ProjectHAB takes no responsibility for damages or corruption due to following these instructions. You do so at your own risk. If you are not confident editing files, please ask someone who is.

Steve Smith