Home

Awesome

svg2mod

This is a small program to convert Inkscape SVG drawings to KiCad footprint module files. It uses cjlano's python SVG parser and drawing module to interpret drawings and approximate curves using straight line segments. Module files can be output in KiCad's legacy or s-expression (i.e., pretty) formats. Horizontally mirrored modules are automatically generated for use on the back of a 2-layer PCB.

Usage

usage: svg2mod.py [-h] -i FILENAME [-o FILENAME] [--name NAME] [--value VALUE]
                  [-f FACTOR] [-p PRECISION] [-d DPI] [--front-only] [--format FORMAT]
                  [--units UNITS]

Convert Inkscape SVG drawings to KiCad footprint modules.

optional arguments:
  -h, --help            show this help message and exit
  -i FILENAME, --input-file FILENAME
                        name of the SVG file
  -o FILENAME, --output-file FILENAME
                        name of the module file
  --name NAME, --module-name NAME
                        base name of the module
  --value VALUE, --module-value VALUE
                        value of the module
  -f FACTOR, --factor FACTOR
                        scale paths by this factor
  -p PRECISION, --precision PRECISION
                        smoothness for approximating curves with line segments
                        (float)
  -d DPI, --dpi DPI     DPI of the SVG file (int)
  --front-only          omit output of back module (legacy output format)
  --format FORMAT       output module file format (legacy|pretty)
  --units UNITS         output units, if output format is legacy (decimil|mm)

SVG Files

svg2mod expects images saved in the uncompressed Inkscape SVG (i.e., not "plain SVG") format.

Layers

Layers must be named (case-insensitive) according to the following rules:

Inkscape layer nameKiCad layer(s)KiCad legacyKiCad pretty
CuF.Cu, B.CuYesYes
AdhesF.Adhes, B.AdhesYesYes
PasteF.Paste, B.PasteYesYes
SilkSF.SilkS, B.SilkSYesYes
MaskF.Mask, B.MaskYesYes
Dwgs.UserDwgs.UserYes--
Cmts.UserCmts.UserYes--
Eco1.UserEco1.UserYes--
Eco2.UserEco2.UserYes--
Edge.CutsEdge.CutsYesYes
FabF.Fab, B.Fab--Yes
CrtYdF.CrtYd, B.CrtYd--Yes

Note: If you have a layer "Cu", all of its sub-layers will be treated as "Cu" regardless of their names.