Skip to main content

Convert an SVG file to a KiCad footprint.

Project description

svg2mod

Build Status GitHub last commit

PyPI - License

PyPI - Python Version

PyPI

@mtl is no longer active. https://github.com/svg2mod/svg2mod is now the maintained branch.

This is a small program to convert Inkscape SVG drawings to KiCad footprint module files. It uses a fork 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

Python 3

Installation

pip3 install svg2mod

Example

svg2mod -i input.svg -p 1.0

Usage

usage: svg2mod [-h] -i FILENAME [-o FILENAME] [-c] [-pads] [-v] [-x] [-d DPI]
               [-f FACTOR] [-p PRECISION] [--format FORMAT] [--name NAME]
               [--units UNITS] [--value VALUE]

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
  -c, --center          Center the module to the center of the bounding box
  -pads, --convert-pads
                        Convert any artwork on Cu layers to pads
  -v, --verbose         Print more verbose messages
  -x, --exclude-hidden  Do not export hidden layers
  -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
                        (float)
  --format FORMAT       output module file format (legacy|pretty)
  --name NAME, --module-name NAME
                        base name of the module
  --units UNITS         output units, if output format is legacy (decimil|mm)
  --value VALUE, --module-value VALUE
                        value of the module

SVG Files

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

  • Drawings should be to scale (1 mm in Inscape will be 1 mm in KiCad). Use the --factor option to resize the resulting module(s) up or down from there.
  • Paths, Rect, and Circles (Ellipse) are 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).
    • A path with a filled area inside a hole will not work properly. You must split these apart into two seperate paths.
    • Transparent fills and strokes with be ignored
  • Groups may be used. However, styles applied to groups (e.g., stroke-width) are not applied to contained drawing elements. In these cases, it may be necessary to ungroup (and perhaps regroup) the elements.
  • Layers must be named to match the target in kicad. The supported layers are listed below.
  • Other types of elements such as arc are not supported.
    • 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 Yes Yes
B.Cu 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

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

svg2mod-0.1.4.1.tar.gz (23.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

svg2mod-0.1.4.1-py3-none-any.whl (26.1 kB view details)

Uploaded Python 3

File details

Details for the file svg2mod-0.1.4.1.tar.gz.

File metadata

  • Download URL: svg2mod-0.1.4.1.tar.gz
  • Upload date:
  • Size: 23.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.0 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.6.7

File hashes

Hashes for svg2mod-0.1.4.1.tar.gz
Algorithm Hash digest
SHA256 a130f36829a6eafc93f142adb668d266ba9db0b438974cddf7be1c0b65b10348
MD5 70e0a1be169de8433a7123ac39dd3fee
BLAKE2b-256 55250b002a9fdaaeaa7d65e44d152aeb64c8a829955945fad5baaf59d46d3b4c

See more details on using hashes here.

File details

Details for the file svg2mod-0.1.4.1-py3-none-any.whl.

File metadata

  • Download URL: svg2mod-0.1.4.1-py3-none-any.whl
  • Upload date:
  • Size: 26.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.0 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.6.7

File hashes

Hashes for svg2mod-0.1.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b11cd3fc13341e63654796bf866606e6bff024a49bb0fe172a4987dfc3fba162
MD5 fa57396d5aeb296ec69ff7c16051ba29
BLAKE2b-256 9e5a849705cc59a3ba5704bec8e2cd42cb58282a90f5b8ec316480a013692ea5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page