The main goal of madparts is to make electronic footprints in a programmatic way. This is done by making each footprint a small program, giving you huge expressiveness. In order to play nice with existing CAD packages, export and import from/to both eagle and kicad are supported. Import does pattern detection detecting of single, dual or quad package formations. The footprint program is continously compiled, giving instant graphical feedback of your changes as you type. Because each footprint is a separate file, collaboration is easy. Just stick the files in a version management system.

Why a new footprint editor?

I was getting a bit tired spending tons of mouse-clicks making an electronics footprint in a CAD program. Madparts is a tool which is more compatible with my way of working, and it'll save me time.

Why are footprints code?

When you make a new footprint you start from the specification from the vendor. Then you do calculations to adjust them to your needs, tool limits, ... If your footprint is code you can put the calculations right there in the footprint, documenting your approach for yourself and others. If there turns out to be a problem you can look back and see what went wrong, and make (and document!) the needed changes.

Does that mean I have to write code?

Probably. Most of the time you can just clone an existing footprint and adjust the numbers. There are plenty of examples available to start from.

Why coffeescript?

Coffeescript is compact and I think it is still quite easy to understand by most people with just a tiny bit of coding experience.

Why not python?

Indeed madparts is written in python, so python would be rather trivial to add. However python is much more verbose then coffeescript. Maybe the option to use python will appear some time in the future.

How about working together with other people on footprints, or sharing?

As each footprint is just a file, you can very easily share those files using a version management system like git. (Or use something like dropbox or google drive, if you don't like having a version management system)

Is there a central github repo where we can all share footprints?

This is an excellent idea and I hope someone sets this up and maintains it. Let me know if you do. For now an older subset of my own footprints can be found at madparts-parts

Why is each footprint a separate file?

This makes sense if you want to start collaborating with other people via a version management system. You don't want to have to merge files each time someone made a change to one footprint.

Why were footprints called something like 9364e38b40644665a3c8c07a5f2f3190.coffee in previous releases?

This was part of the footprint management system that was integrated in the 1.x releases of madparts. The 2.0 release has removed all this and filenames are up to you again.

how can I print a footprint?

You can't yet. It is a feature that is planned but not yet there. For now you can export to eagle or kicad and print from there.

how can you make improvements to the program without breaking the existing footprints?

There is a #format meta-tag in each footprint. Madparts uses this to use the right version of the utilities code for that particular version of footprint. The current format is 2.0.

is import/export from/to eagle cad supported?

Yes.

is import/export from/to kicad supported?

Yes.

is import/export from/to geda supported?

No. If you're interested in contributing geda support I'm happy to assist. Have a look at https://github.com/erichVK5/KicadModuleToGEDA for converting kicad to geda.

Will there be a symbol editor as well?

Maybe, one day :)

Where do I report bugs or feature requests?

Use the issue tracker in github.

What unit is used?

Milimeters are used everywhere. You can suffix a number with mi or mil for mils and with in for inches. For example 1in, 6mi. Note that no space is allowed between the number and the suffix. These imperial units are just converted back to milimeter in a preprocessor step and the entire program still works with millimeters.

Using the program should be quite straightforward. A menu bar at the top provides export and other functions. The right side of the program always shows a rendering of the currently selected footprint.

programs

madparts

This is the main program. Start it with a .coffee file to edit it. Starting it without a file will pop up the open dialog allow you to select a file.

madparts-import

Use this program to import a footprint. Start it up and it will pop up a dialog asking to open a kicad or eagle library and then allows you to select a footprint to import.

Eagle

typical eagle workflow

  • Create a new eagle library in eagle where you want to work with
  • choose a footprint
  • press CTRL-E, and choose that eagle library
  • choose another footprint
  • press CTRL-E again to re-use the last chosen library
  • modify the footprint
  • press CTRL-E again to re-use the last chosen library
  • ...

eagle quirks

If you saved your footprint to a library, you may find that you can't select the library anymore for adding new parts to a schematic. It is as of yet unclear to me why this is the case. The workaround is to open the library from the library browser and save it. My guess is that the eagle XML parser is picky in some way.

Kicad

typical Kicad workflow

Kicad has two library formats, the old .mod and the new .pretty. Code to support the old format is kept around for legacy reasons but as current kicad has switched to the new format the new format code is more heavily used and has more bugfixes applied. Note that unfortunately kicad caches the .pretty library content so you have to restart kicad to see a newly added footprint. If you just overwrite and existing footprint you can just change the footprint to the same via kicad in pcbnew and it will take the new footprint. I have some ideas to better integrate with Kicad but they are not there yet ;)

Editing footprints

Editing footprints is almost real-time. This means that the code is compiled when you stop typing and the result is immediately shown on the display part of the editor. If there is a compilation error an error window will pop up from the bottom of the editor showing the error.

The footprint is automatically saved each time it compiles successfully. If your computer is really slow you may want to turn of automatic compilation in the preferences. You can then do manual compilation with CTRL-F.

If you come from an older version of madparts you may want to check if auto compile is turned on as some older versions shipped with it turned off by default, meaning you have to turn it on yourself.

Command-line

It is possible to use the madparts-cli program for importing and exporting footprints. Some examples of usage follow.

list an eagle library

madparts-cli ls SparkFun-LED.lbr
APA3010SF4C
LED5MM
LED3MM
LED-1206
LED-0603
...
LED-TRICOLOR-5050-IC

list a .kicad_mod module file

As expected these contain only one module

madparts-cli ls 0603.kicad_mod 
0603

list a .pretty kicad module directory

This will list all the .kicad_mod modules contained in that directory.

madparts ls offset.pretty/
0603
MYCONN3
NUM_IV-9

list a .mod classic kicad module file

madparts-cli ls Crystals_RevB_20Apr2013.mod 
Crystal_Round_Horizontal_2mm_RevA_25Apr2012
Crystal_Round_Vertical_3mm_RevA_25Apr2012
Crystal_Round_Vertical_2mm_RevA_25Apr2012
...

import an eagle footprint

madparts-cli import SparkFun-LED.lbr LED3MM
SparkFun-LED.lbr/LED3MM written to LED3MM.coffee

import a .kicad_mod module file

As only one footprint is contained in a .kicad_mod file, the second footprint name argument can be left off.

madparts-cli import 0603.kicad_mod 
0603.kicad_mod/0603 written to 0603.coffee.
import a footprint from a kicad .pretty footprint directory
madparts import offset.pretty MYCONN3
in dev tree
offset.pretty/MYCONN3 written to MYCONN3.coffee.

import a footprint from a .mod classic kicad footprint file

madparts-cli import MYCONN3.mod 0603
in dev tree
MYCONN3.mod/0603 written to 0603.coffee.

export a footprint to eagle

madparts-cli export LED3MM.coffee madparts.lbr
LED3MM compiled.
Exported to madparts.lbr.

export a footprint to a .kicad_mod module file

madparts-cli export examples/0603.coffee 0603.kicad_mod 
in dev tree
0603 compiled.
Exported to 0603.kicad_mod.

export a footprint to a kicad .pretty footprint directory

madparts-cli export examples/0603.coffee offset.pretty
in dev tree
0603 compiled.
Exported to offset.pretty.

This will create a 0603.kicad_mod file in the offset.pretty directory.

export a footprint to a .mod classic kicad footprint file

madparts-cli export examples/0603.coffee MYCONN3.mod 
in dev tree
0603 compiled.
Exported to MYCONN3.mod.

Format

For the impatient, all the coffeescript constructs can be found here.

For actual usage I suggest looking at the examples or just try things.

Some older documentation is available here.

Also check out this blog post for another detailed example.

Program Structure

Example

Let's look in detail at an example. Here is the full example, we'll go through it part by part below.

#format 2.0
#name TQFP44
#desc TQFP44 example
#desc this package is used by e.g. the Atmel ATMEGA1284P-AU

footprint = () ->

  size = 11
  half = size / 2
  half_line_size = half - 1.5
  line_width = 0.25
  num_pads = 44
  e = 0.8

  name = new Name (half + 1.5)
  value = new Value (-half - 1.5)

  pad = new Smd
  pad.dx = 1.67
  pad.dy = 0.36
  pad.ro = 50

  pads = quad pad, num_pads, e, size

  pads[1-1].ro = 100

  silk = silk_square half_line_size, line_width

  dot = new Disc (line_width)
  dot.x = -half 
  dot.y = half - 0.7

  combine [name, value, pads, silk, dot]

Meta

The meta block is special as it is not actual coffeescript code. It contains some meta data about the footprint.

#format 2.0
#name TQFP44
#desc TQFP44 example
#desc this package is used by e.g. the Atmel ATMEGA1284P-AU

#format indicates the footprint format. The current active format is 2.0. This tells the program which version of the footprint generating library it should use for executing the footprint.

#name is the short name of the footprint. Multiple footprints are allowed to have the same footprint but it might get confusing :) This is what is used as name when you export to kicad or eagle.

#desc A detailed description of the footprint. Multiple lines can be made by multiple #desc lines.

footprint function

footprint = () ->

All footprints are coffeescript functions called footprint. Your footprint will always have this line. The lines under this are the coffeescript code for the footprint and MUST be indented. I suggest using 2 spaces.

constant definitions

size = 11
half = size / 2
half_line_size = half - 1.5
line_width = 0.25
num_pads = 44
e = 0.8

Although not mandatory at all, typically you will want to define some constants that can be used within your footprint code. Naming is arbitrary, but some things are typically done. size is the width of the footprint, sometimes also known as between. In this case it will indicate the distance between the middles of opposite pads. e is the distance between pads, ...

name and value label

name = new Name (half + 1.5)
value = new Value (-half - 1.5)

The argument to the constructor is the Y position. Typically you want these centered on the Y-axis. As you can see it uses a constant defined above.

definition of the pad

pad = new Smd
pad.dx = 1.67
pad.dy = 0.36
pad.ro = 50

Here a simple square surface pad is defined. It is constructed without arguments and then it's dx, dy and ro parameters are set.

generating the pads

pads = quad pad, num_pads, e, size

We use the high-level construct quad here to construct a quad pad footprint.

Modifying the first pad

pads[1-1].ro = 100

For niceness we modify the first pad to have fully rounded corners.

Silkscreen

silk = silk_square half_line_size, line_width

dot = new Disc (line_width)
dot.x = -half 
dot.y = half - 0.7

We then draw a square and a disk.

Combining everything

combine [name, value, pads, silk, dot]

The last step of a footprint is typically combining everything together in one big list. The program expects such a list. Failure to do so will result in a compile error.

Linux

Install the following packages via your distribution package manager:

  • python (tested with 2.7)
  • numpy (tested with 1.7.1)
  • pyside (tested with 1.1.2)
  • python-opengl (tested with 3.0.1)
  • python-bs4 (beautiful soup) (tested with 4.2.0)
  • python-imaging (tested with 1.1.7)
Finally download a package of madparts 2.0.1 for Debian 8 from madparts_2.0.2-1_all.deb

Win32

Download the zipfile from madparts-2.0.2.zip. Unzip the zipfile and execute the madparts.exe contained in the madparts-2.0.2 directory. It might be convenient to associate the .coffee file extension with the madparts.exe.

OS-X

For OS-X Montain Lion an app is provided. Download it from madparts-2.0.2-osx.zip, unzip and run it. For other variants of OS-X please look in the BUILD.osx file.

Source

v2.0.2.tar.gz

All the code lives in github.