Python Port of Gordon Williams' svg2eagle Converter
usage: svg2eagle.py [-h] [-s SCALEFACTOR] [-l EAGLELAYERNUMBER]
[-v] [-o {b,ls,lib}] [-n SIGNALNAME] [-u SUBSAMPLING]
[-t TRACEWIDTH] [-a {tl,cl,bl,tc,cc,bc,tr,cr,br}]
imagePath
positional arguments:
imagePath Path to SVG image
optional arguments:
-h, --help show this help message and exit
-s SCALEFACTOR Text Height in inches (same as EAGLE text size value)
-l EAGLELAYERNUMBER Layer in EAGLE to create label into (default is tPlace
layer 21)
-v Verbose mode (helpful for debugging)
-o {b,ls,lib} Output Mode ('b'=board script, 'ls'=library script,
'lib'=library file)
-n SIGNALNAME Signal name for polygon. Required if layer is not 21
(default is 'GND')
-u SUBSAMPLING Subsampling Rate (larger values provide smoother curves
with more points)
-t TRACEWIDTH Trace width in mm
-a {tl,cl,bl,tc,cc,bc,tr,cr,br}
Footprint anchor position (default:cl)
-w {w,a} Output writing mode (default:w)
-d DESTINATION Output destination filename (extension depends on -o
flag)
Your input image can be any SVG file and svgtoeagle will ATTEMPT to import all curves. However, for best results:
svgtoeagle.py is only able to read and convert line and poly objects, so shape primitives and text should all be converted to curves before svgtoeagle gets to touch it.
Unlike the original svgtoeagle, which runs in a web browser, svgtoeagle.py never renders the input svg file. This means, unfortunately, that certain types of transforms get ignored. Technically, svgtoeagle.py will happily parse groups so long as there are no group transforms. The best way to avoid group transforms is simply to ungroup all curves in your SVG file. If a group is detected in your input file, svgtoeagle.py will still attempt to import the file but will also warn you that groups are present.
Only curves and polygons with fill or stroke parameters will be translated. After removing groups, some SVG files will lack fill or stroke color. If there are elements missing from your image, open it in Inkscpae and check that these parameters are not "Unset"
Keep in mind that svgtoeagle will sample all curves in the file with the same resolution. If your file has multiple elements in it with very different sizes and "densities" then you may consider splitting them into separate svg files and then importing them with optimal subsampling (-u) factors for each.
Inkscape is a free, open-source vector graphics program for all platforms that does a good job of creating SVG files that svgtoeagle.py likes. Here are the steps that I've found give satisfactory results:
Step 4: Check Stroke and Fill (Shift+Ctrl+F) properties. Add stroke or fill to elements with "Unset" property
These steps are usually enough to convert an unfriendly SVG.
This argument controls the output size of the image. By default, SVG files that contain size information will convert 1:1
This argument controls which EAGLE layer the image is written to. Default value is 21 (tPlace)
If something gets borked, try running again with -v
to see what's happening under the hood. If a job seems like it's taking too long, abort and then run in verbose mode to see if it's actually stuck or just very very long. Verbose mode is the closest that svgtoeagle.py has to a heartbeat.
This argument controls which format the image output is generated for
By default, svgtoeagle.py will generate a file called output.scr
which can be run in the board editor.
Library script mode will generate a file called output.scr
which can be run in the library footprint editor.
Library package mode will generate a file called output.lbr
which is an EAGLE library file containing the specified image
This argument defines the EAGLE signal name of the output, which is only required for metal layers. It is GND
by default.
This argument essentially defines the resolution of the output. A smaller number will produce smoother curves but larger files. Note: Smaller scale factors require smaller subsampling factors
Tracewidth of output in mm
In library package output mode, the position of the anchor point can be specified using the -a
argument. The default value is cl
The following values are permissible:
tl - top left
cl - center left
bl - bottom left
tc - top center
cc - center center
bc - bottom center
tr - top right
cr - center right
br - bottom right
By default, svgtoeagle.py with overwrite the output file. Running with the -w a
option, however, will run buzzard.py in "append mode,"
adding the specified image to the existing output file.
Using the -d
flag will allow you to specify the name of the output file. The file extension will automatically be selected based on
the output format.