SVG to KiCAD footprint with Inkscape
Happy new year! And to celebrate, here’s a plugin for Inkscape that converts SVG documents into KiCAD footprints.
Quick recipe: Copy the files kicad_footprint.py
kicad_footprint.ink
and
kicad_footprint_output.py
into Inkscape’s share/extensions/
directory.
The capabilities are pretty crude but the initial results are promising. Here is the SVG document (100mm by 100mm) on Inkscape:
And here it is exported into KiCAD (grid is 10mm)
Interface is simple, many features are missing but works fine for quick SVG exports into KiCAD. Extension also registers a “Save As…” file format that will export the drawing using all the default options.
As usual, source is available on my source repository.
Limitations
The KiCAD footprint format has a limitation in so far it cannot “punch holes” on polygons. That means that a “ring” shape will be rendered improperly. To work around this issue, any shape with holes in it must be split into multiple shapes with no holes inside of them. While a future revision might do the splitting automatically (unlikely) this isn’t very hard to do.
Here is a shape with a “hole” in it; A ring.
And this is the incorrect result of trying to export it to KiCAD without splitting it:
To address this issue, we will split the ring into two halves, so we draw a a line over it:
Select both paths:
Apply the “Division” operation:
At this point, the ring is split in halves, if we temporarily separate them they will look like this:
If we then save as KiCAD footprint, we can test the result is now correct.