Skip to main content

svg2mod

GitHub Workflow Status GitHub last commit

PyPI PyPI - Python Version PyPI - Downloads

PyPI - License

GitHub Sponsors

This is a program / library to convert SVG drawings to KiCad footprint module files.

It includes a modified version of 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.

Requirements

Installation

pip install svg2mod

Don't want to install the application?

You can use a 3rd party web application instead:

Showcase

We'd love to see the amazing projects that use svg2mod.

If you have a project you are proud of please post about it on our github discussions board

GitHub Discussions

Example

svg2mod input.svg

Usage

usage: svg2mod [-h] [-i FILENAME] [-o FILENAME] [-c] [-P] [-v] [--debug] [-x]
               [--force LAYER] [-d DPI] [-f FACTOR] [-p PRECISION]
               [--format FORMAT] [--name NAME] [--units UNITS] [--value VALUE]
               [-F DEFAULT_FONT] [-l]
               [IN_FILENAME]

Convert Inkscape SVG drawings to KiCad footprint modules.

positional arguments:
  IN_FILENAME           Name of the SVG file

optional arguments:
  -h, --help            show this help message and exit
  -i FILENAME, --input-file FILENAME
                        Name of the SVG file, but specified with a flag.
  -o FILENAME, --output-file FILENAME
                        Name of the module file
  -c, --center          Center the module to the center of the bounding box
  -P, --convert-pads    Convert any artwork on Cu layers to pads
  -v, --verbose         Print more verbose messages
  --debug               Print debug level messages
  -x, --exclude-hidden  Do not export hidden objects
  --force LAYER, --force-layer LAYER
                        Force everything into the single provided layer
  -d DPI, --dpi DPI     DPI of the SVG file (int)
  -f FACTOR, --factor FACTOR
                        Scale paths by this factor
  -p PRECISION, --precision PRECISION
                        Smoothness for approximating curves with line
                        segments. Input is the approximate length for each
                        line segment in SVG pixels (float)
  --format FORMAT       Output module file format (legacy|pretty|latest).
                        'latest' introduces features used in kicad >= 6
  --name NAME, --module-name NAME
                        Base name of the module
  --units UNITS         Output units, if output format is legacy (decimal|mm)
  --value VALUE, --module-value VALUE
                        Value of the module
  -F DEFAULT_FONT, --default-font DEFAULT_FONT
                        Default font to use if the target font in a text
                        element cannot be found
  -l, --list-fonts      List all fonts that can be found in common locations

SVG Files

svg2mod expects images saved in the uncompressed Inkscape SVG (i.e., not "plain SVG") format. This is so it can associate inkscape layers with kicad layers

  • Drawings should be to scale (1 mm in Inkscape will be 1 mm in KiCad). Use the --factor option to resize the resulting module(s) up or down from there.

  • Most elements are fully supported.

    • A path may have an outline and a fill. (Colors will be ignored.)
    • A path may have holes, defined by interior segments within the path (see included examples).
    • 100% Transparent fills and strokes with be ignored.
    • Text Elements are partially supported
  • Groups may be used. Styles applied to groups (e.g., stroke-width) are applied to contained drawing elements.

  • Layers or items must be named to match the target in kicad. The supported layers are listed below. They will be ignored otherwise.

    • These are pulled from inkscape:label but will pull from id if the label isn't set.
  • If there is an issue parsing an inkscape object or stroke convert it to a path.

    • Use Inkscape's "Path->Object To Path" and "Path->Stroke To Path" menu options to convert these elements into paths that will work.

Layers

This supports the layers listed below. They are the same in inkscape and kicad:

KiCad layer(s) KiCad legacy KiCad pretty
F.Cu 1 Yes Yes
B.Cu 1 Yes Yes
F.Adhes Yes Yes
B.Adhes Yes Yes
F.Paste Yes Yes
B.Paste Yes Yes
F.SilkS Yes Yes
B.SilkS Yes Yes
F.Mask Yes Yes
B.Mask Yes Yes
Dwgs.User Yes Yes
Cmts.User Yes Yes
Eco1.User Yes Yes
Eco2.User Yes Yes
Edge.Cuts Yes Yes
F.Fab -- Yes
B.Fab -- Yes
F.CrtYd -- Yes
B.CrtYd -- Yes
Drill.Cu 1 2 -- Yes
Drill.Mech 1 2 -- Yes
*.Keepout 1 3 -- Yes 4

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

Layer Options

Some layers can have options when saving to the newer 'pretty' format.

The options are separated from the layer name by :. Ex F.Cu:...

Some options can have arguments which are also separated from the option key by :. If an option has more than one argument they are separated by a comma. Ex: F.Cu:Pad:1,mask.

If a layer has more than one option they will be separated by ; Ex: F.Cu:pad;...

Supported Arguments:

  • Pad

    Any copper layer can have the pad specified. The pad option can be used solo (F.Cu:Pad) or it can also have it's own arguments. The arguments are:

    • Number If it is set it will specify the number of the pad. Ex: Pad:1

    • Paste (Not available for Drill.Cu)

    • Mask (Not available for Drill.Cu)

  • Allowed

    Keepout areas will prevent anything from being placed inside them. To allow some things to be placed inside the keepout zone a comma separated list of any of the following options can be used: tracks,vias,pads,copperpour,footprints

  • Hatch

    Keepout areas have different hatching styles. This allows customization of the appearance of hatching when converting from an svg, Ex: F.Keepout:Hatch:edge. All available hatch options are none, edge, full.

  1. These layers can have arguments when svg2mod is in pretty mode ↩ ↩2 ↩3 ↩4 ↩5

  2. Drills can only be svg circle objects. The stroke width in Drill.Cu is the pad size and the fill is the drill size. ↩ ↩2

  3. The * can be { *, F, B, I } or any combination like FB or BI. These options are for Front, Back, and Internal. ↩

  4. Only works in Kicad versions >= v6 (--format latest). ↩

Metadata

Release files for svg2mod 1.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for svg2mod 1.2.2
File Size Uploaded
svg2mod-1.2.2.tar.gz 50.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for svg2mod 1.2.2
File Interpreter ABI Platform
svg2mod-1.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 102.5 kB

Release files / svg2mod-1.2.2.tar.gz

Download URL svg2mod-1.2.2.tar.gz
Size 50.3 kB
Tags Source
SHA-256 checksum
How to use checksums
f4a31c2ab368d43155be8a4e48d26ac6006f803a78a1e867a2f6b5148466ac54
BLAKE2b-256 checksum
How to use checksums
7d0977221ad55b446c2aa7a0dc0590e9808189777cc40748032aecca868d956a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.21

Release files / svg2mod-1.2.2-py3-none-any.whl

Download URL svg2mod-1.2.2-py3-none-any.whl
Size 52.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bd8cbc9e46611233050b200015a2cc957d718bce459d00f92f7edb97b36f2081
BLAKE2b-256 checksum
How to use checksums
6ea8d18d4bf92f33c9f4f82dc25b53c815a9cb5d8b05d241b67b1827750fb9c0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.21

Release history Release notifications | RSS feed

This release

1.2.2 This release

2 release files

1.2.1

2 release files

1.2

2 release files

1.1

2 release files

1.0

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page