Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Python 3 and update documentation #33

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
# 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](https://github.com/cjlano/svg) 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.

## Requirements

Python 3

## Installation

```pip3 install git+https://github.com/zirafa/svg2mod```

Note: ```python3 setup.py install``` does not work.

## Example

```svg2mod -i input.svg -p 1.0```

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

Expand Down
2 changes: 1 addition & 1 deletion svg2mod/svg/svg/svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ def __init__(self, elt=None):
self.name = ""
if elt is not None:

for id, value in elt.attrib.iteritems():
for id, value in elt.attrib.items():

id = self.parse_name( id )
if id[ "name" ] == "label":
Expand Down
10 changes: 5 additions & 5 deletions svg2mod/svg2mod.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ def _prune( self, items = None ):
if items is None:

self.layers = {}
for name in self.layer_map.iterkeys():
for name in self.layer_map.keys():
self.layers[ name ] = None

items = self.imported.svg.items
Expand All @@ -564,7 +564,7 @@ def _prune( self, items = None ):
if not isinstance( item, svg.Group ):
continue

for name in self.layers.iterkeys():
for name in self.layers.keys():
#if re.search( name, item.name, re.I ):
if name == item.name:
print( "Found SVG layer: {}".format( item.name ) )
Expand Down Expand Up @@ -653,7 +653,7 @@ def _write_module( self, front ):
front,
)

for name, group in self.layers.iteritems():
for name, group in self.layers.items():

if group is None: continue

Expand Down Expand Up @@ -1094,7 +1094,7 @@ def _write_library_intro( self ):

# Write index:
for module_name in sorted(
self.loaded_modules.iterkeys(),
self.loaded_modules.keys(),
key = str.lower
):
self.output_file.write( module_name + "\n" )
Expand All @@ -1111,7 +1111,7 @@ def _write_preserved_modules( self, up_to = None ):
up_to = up_to.lower()

for module_name in sorted(
self.loaded_modules.iterkeys(),
self.loaded_modules.keys(),
key = str.lower
):
if up_to is not None and module_name.lower() >= up_to:
Expand Down