Close

Part 1 of n

A project log for Eagle parts, by family, using python

A quick collection of python scripts to make a whole family of parametric parts in eagle.

bveinabveina 04/22/2017 at 03:020 Comments

The goal of the project is to make a lot of similar components as quickly as possible using python. the first step was to understand how to do a single component using only the command bar.

I'll write this log in the order I discovered commands, not the final order they are used.


  1. PAD/SMD

the core command needed to create a component will be familiar to anyone who has made their own component in eagle. the PAD command places a through hole connection and the SMD command places a surface mount connection.

the help documentation is pretty good and lists the following information for the SMD command

SMD [x_width y_width] [-roundness] [orientation] [flags] ['name'] •..

boom

And now i can place a pa-wait what is that DOT at the end?? well the documentation tells me that is a mouse click. that isn't very useful for scripting. however, that dot can also be replaced with "(xCoord yCoord)".

now the pad code begins to take shape:

myCMDs=[]
cmdTemplate = "SMD {0:f} {1:f} '{2:s}' ({3:f} {4:f});"

for i in range(1,p+1):
      myCMDs.append(cmdTemplate.format(padW,padH,str(i),x,y))

This will create pads named '1', '2',...,'n', x and y locations. Calculating X and Y are relatively straightforward. X will increase by the pin pitch (0.1"), and Y will alternate.

  hpitch = 0.1
  yPrime = +(padH/2)
  yAlt   = -(padH/2)
  x=0
  p=6
  for i in range(1,p+1):
    if i%2==1:
      y=yPrime
    else:
      y=yAlt
    myCMDs.append(cmdTemplate.format(padW,padH,str(i),x,y))
    x+=hpitch

The last step in the footprint was to add a quick silkscreen for the plastic part of the header.

cmd1Template = "WIRE .008 ({0:f} {1:f}) ({2:f} {3:f}) ({0:f} {1:f}) ;"
myCMDs.append("LAYER tDocu;")
myCMDs.append("Set Wire_Bend 0;")
myCMDs.append(cmd1Template.format(-.05,0.05,(p)*.1-0.05,-0.05))
myCMDs.append("Set Wire_Bend 4;")
myCMDs.append(cmd1Template.format(-.05,0.05,(p)*.1-0.05,-0.05))
myCMDs.append("write")

This code required a few more Eagle commands:

Boom:

One down, 199 to go.

Discussions