GithubHelp home page GithubHelp logo

badgeek / svg2shenzhen Goto Github PK

View Code? Open in Web Editor NEW
773.0 35.0 78.0 17.17 MB

Convert Inkscape SVG drawings to KiCad PCB and footprint modules

License: GNU General Public License v3.0

CMake 0.59% C++ 95.79% GLSL 0.09% C 2.12% Makefile 0.60% Shell 0.03% Python 0.77%
pcb kicad-pcb inkscape pcb-art badge art openhardware badgelife

svg2shenzhen's Introduction

Svg2Shenzhen

Sadly this project is discontinued

There are better tools to create artistic pcb here is one that i recommend: https://github.com/wntrblm/Gingerbread

Inkscape extension for exporting drawings into a KiCad PCB.

showcase

Features

  • Draw Any kind of shapes without restriction
  • Supports Drill Pad, and custom drill size
  • Supports Edge Cut (PCB Shape)
  • Works on OSX, Windows and Linux

Install

Warning: starting from 0.2.18 svg2shenzhen only support Inkscape 1.0 and above

  1. Download the latest version (0.2.18.7)
  1. Extract and copy the files into the directory indicated in Inkscape under Edit -> Preferences -> System: User extensions

Step by Step Guide with Screenshot

  • Go to your extracted folder it should look like this

windowsStep0

  • Copy all files ("svg2shenzhen" folder + svg2shenzhen_about.inx + svg2shenzhen_export.inx + svg2shenzhen_prepare.inx)
  • Open Inkscape and go Edit --> Preferences

windowsStep1

  • Under Preferences go to System, Now in System info you will see option User extensions: this is the path of extension. You can hit on Open icon and it will open up the folder.

windowsStep2

  • Paste all the files copied

windowsStep3

  • Restart Inkscape

How to

In Inkscape:

  1. Extension > Svg2Shenzhen > Prepare Document
  2. Choose layer (F.Cu.. etc)
  3. Draw PCB
  4. Extension > Svg2Shenzhen > Export KiCad

Download and open Example PCB

Tutorials

Layername definitions

  1. After the Prepare Document step, only two fabrication layers are used: Edge.Cuts and Drill, and for the different PCB-layers, only the F.Cu layer is active. The others have the post-fix "-disabled" in their layer name; change this by removing this post-fix to enable more layers.
  2. Special use of the solder-mask layers F.Mask and B.Mask: Due to the fabrication standard of PCB manufacturing, when enabled, this will lead to the solder-mask NOT being present where there are black areas in your design. This is kinda PCB/KiCad standard, but can be confusing. If you want to Get-What-You-See from Inkscape, meaning that you really draw the color where you want the solder-mask to be, change the layer name to F.Mask-invert
  3. Super easy simple PCB with exposed copper surrounded by solder-mask, can be generated automatically by leaving the F.Mask layer empty and renaming it to F.Mask-auto.
  4. Feel free to add your own layers, for testing graphics and designing stuff. All these other layers will be ignored.

Tips

  1. For Edge.Cut layers, you need to convert any polygons or objects to paths with only an outline, no fill. Don't use any groups on Edge.Cut layers, and if you have paths with inner cut-outs, break them apart into separate paths.
  2. For Drill layers, place circle objects, and they will be converted into drill pads in KiCad with the same diameter. These drills will not have annular rings, unless you also add copper to the F.Cu and B.Cu layers. Don't use any groups on the Drill layer either.

References

Videos

Support this project

This project is developed independently and without any connection to funding or big collective or organization. Donation is highly appreciated. Go to https://www.patreon.com/badgeek to become a patron and support this project

Contributors

Credits

svg2shenzhen's People

Contributors

5shekel avatar antonbilbaeno avatar badgeek avatar dashyfox avatar dusjagr avatar fdb-git avatar fstokke avatar hoijui avatar iharshadec avatar kasbah avatar onitake avatar sodium-hydrogen avatar twinkletwinkie avatar urish avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

svg2shenzhen's Issues

Error with Inskcape 1.0 beta and Catalina MacOS

Hi

I am using the lastet version of inskcape because I have MacOS Catalina, i have the next error in export kicad

export.py:224: DeprecationWarning: Effect.OptionParser or `optparse` has been deprecated and replaced with `argparser`.You must change `self.OptionParser.add_option` to `self.arg_parser.add_argument`; the arguments are similar.
  self.OptionParser.add_option("--path", action="store", type="string", dest="path", default="~/", help="")
export.py:225: DeprecationWarning: Effect.OptionParser or `optparse` has been deprecated and replaced with `argparser`.You must change `self.OptionParser.add_option` to `self.arg_parser.add_argument`; the arguments are similar.
  self.OptionParser.add_option('-f', '--filetype', action='store', type='string', dest='filetype', default='jpeg', help='Exported file type')
export.py:226: DeprecationWarning: Effect.OptionParser or `optparse` has been deprecated and replaced with `argparser`.You must change `self.OptionParser.add_option` to `self.arg_parser.add_argument`; the arguments are similar.
  self.OptionParser.add_option("--crop", action="store", type="inkbool", dest="crop", default=False)
export.py:227: DeprecationWarning: Effect.OptionParser or `optparse` has been deprecated and replaced with `argparser`.You must change `self.OptionParser.add_option` to `self.arg_parser.add_argument`; the arguments are similar.
  self.OptionParser.add_option("--dpi", action="store", type="float", dest="dpi", default=600)
export.py:228: DeprecationWarning: Effect.OptionParser or `optparse` has been deprecated and replaced with `argparser`.You must change `self.OptionParser.add_option` to `self.arg_parser.add_argument`; the arguments are similar.
  self.OptionParser.add_option("--threshold", action="store", type="float", dest="threshold", default=128.0)
export.py:229: DeprecationWarning: Effect.OptionParser or `optparse` has been deprecated and replaced with `argparser`.You must change `self.OptionParser.add_option` to `self.arg_parser.add_argument`; the arguments are similar.
  self.OptionParser.add_option("--openfactory", action="store", type="inkbool", dest="openfactory", default="true")
export.py:230: DeprecationWarning: Effect.OptionParser or `optparse` has been deprecated and replaced with `argparser`.You must change `self.OptionParser.add_option` to `self.arg_parser.add_argument`; the arguments are similar.
  self.OptionParser.add_option("--openkicad", action="store", type="inkbool", dest="openkicad", default="true")
export.py:231: DeprecationWarning: Effect.OptionParser or `optparse` has been deprecated and replaced with `argparser`.You must change `self.OptionParser.add_option` to `self.arg_parser.add_argument`; the arguments are similar.
  self.OptionParser.add_option("--autoflatten", action="store", type="inkbool", dest="autoflatten", default="true")
export.py:232: DeprecationWarning: Effect.OptionParser or `optparse` has been deprecated and replaced with `argparser`.You must change `self.OptionParser.add_option` to `self.arg_parser.add_argument`; the arguments are similar.
  self.OptionParser.add_option("--debug", action="store", type="inkbool", dest="debug", default=False)
export.py:748: DeprecationWarning: Effect.affect is now `Effect.run()`. The `output` argument has changed.
  e.affect()
export.py:347: DeprecationWarning: self.args[-1] is now self.options.input_file
  curfile = self.args[-1]
Traceback (most recent call last):
  File "export.py", line 752, in <module>
    _main()
  File "export.py", line 748, in _main
    e.affect()
  File "/Applications/Inkscape.app/Contents/Resources/share/inkscape/extensions/inkex/deprecated.py", line 181, in affect
    return self.run(args=args)
  File "/Applications/Inkscape.app/Contents/Resources/share/inkscape/extensions/inkex/base.py", line 123, in run
    self.save_raw(self.effect())
  File "export.py", line 324, in effect
    self.processExportLayer()
  File "export.py", line 348, in processExportLayer
    layers = self.get_layers(curfile)
  File "export.py", line 548, in get_layers
    if  layer_label_name in self.layer_map.iterkeys():
AttributeError: 'dict' object has no attribute 'iterkeys'

Thanks

Setting drill size doesn't seem to work

I tried running the "set drill size" before and after adding some circles but they always come out to 0.8mm when I do the "Kicad PCB" export (need to test mod output too). Why don't we just set them to the diameter of the circles being added anyway?

TypeError: expected a string or other character buffer object

hi, i tried to convert a SVG drawing to KiCAD from Inkscape 0.92, but i always get the following exception:

Traceback (most recent call last):
  File "export.py", line 740, in <module>
    _main()
  File "export.py", line 736, in _main
    e.affect()
  File "/usr/share/inkscape/extensions/inkex.py", line 283, in affect
    self.effect()
  File "export.py", line 313, in effect
    self.processExportLayer()
  File "export.py", line 463, in processExportLayer
    f.write(kicad_drill_string)
TypeError: expected a string or other character buffer object

i have no idea what is going on there...
hope you can help me.

i use Kubuntu 19.04:
Linux my-pc 5.0.0-25-generic #26-Ubuntu SMP Thu Aug 1 12:04:58 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

the inkscape version from ubuntu repository:
Inkscape 0.92.4 (5da689c313, 2019-01-14)

i extracted the extension to the following location:

my-pc:~/.config/inkscape/extensions$ tree .
.
β”œβ”€β”€ svg2shenzhen
β”‚Β Β  β”œβ”€β”€ bitmap2component.exe
β”‚Β Β  β”œβ”€β”€ bitmap2component_linux64
β”‚Β Β  β”œβ”€β”€ bitmap2component_osx
β”‚Β Β  β”œβ”€β”€ export.py
β”‚Β Β  └── prepare.py
β”œβ”€β”€ svg2shenzhen_about.inx
β”œβ”€β”€ svg2shenzhen_export.inx
└── svg2shenzhen_prepare.inx

the content of a simple inkscape file (only a red rectangle):

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->

<svg
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:cc="http://creativecommons.org/ns#"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
   width="210mm"
   height="297mm"
   viewBox="0 0 210 297"
   version="1.1"
   id="svg8"
   inkscape:version="0.92.4 (5da689c313, 2019-01-14)"
   sodipodi:docname="drawing.svg">
  <defs
     id="defs2" />
  <sodipodi:namedview
     id="base"
     pagecolor="#ffffff"
     bordercolor="#666666"
     borderopacity="1.0"
     inkscape:pageopacity="0.0"
     inkscape:pageshadow="2"
     inkscape:zoom="0.35"
     inkscape:cx="-505.71429"
     inkscape:cy="560"
     inkscape:document-units="mm"
     inkscape:current-layer="layer1"
     showgrid="false"
     inkscape:window-width="1920"
     inkscape:window-height="1135"
     inkscape:window-x="0"
     inkscape:window-y="0"
     inkscape:window-maximized="1" />
  <metadata
     id="metadata5">
    <rdf:RDF>
      <cc:Work
         rdf:about="">
        <dc:format>image/svg+xml</dc:format>
        <dc:type
           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
        <dc:title></dc:title>
      </cc:Work>
    </rdf:RDF>
  </metadata>
  <g
     inkscape:label="Layer 1"
     inkscape:groupmode="layer"
     id="layer1">
    <rect
       style="opacity:1;fill:#ff0000;stroke:none;stroke-width:0.26458332"
       id="rect815"
       width="100"
       height="70"
       x="55"
       y="113.5" />
  </g>
</svg>

Only 'help' available from extension

Installed inkscape and svg2shenzhen. When navigating to the extension in inkscape it only has option 0 'help'. Prepare and export do not show up at all. Have tried with a new inkscape blank file, and example svg files plus my own.

Any idea's?
Win 10

How to use other layers?

How to other layers like F.Adhes, Eco1.User etc?
I tried to add these layers with same name but they are not exported.

Svg2Shenzhen fails with Python errors in Inkscape 1.0alpha2

You might be aware that the Inkscape team is currently actively working on the release of Inkscape 1.0. The team already published the second alpha to download. It looks like the Python extension API has slightly changed, so that the extension Svg2Shenzhen is not working any more.

Steps to reproduce:

  1. Download Inkscape 1.0alpha2: https://inkscape.org/release/1.0alpha2/platforms/
  2. Install Svg2Shenzhen in the user extension folder
  3. Open Inkscape 1.0alpha2 with a new document
  4. Run svg2shenzhen using the menu Extensions > Svg2Shenzhen SVGSZVER (note the strange name extension) > 1. Prepare Document…
  5. Choose default parameters and click Apply

What happened?

The document was prepared properly. Size, layers and guides are set up, but the extension returns the following warnings:

prepare.py:24: DeprecationWarning: Effect.OptionParser or `optparse` has been deprecated and replaced with `argparser`.You must change `self.OptionParser.add_option` to `self.arg_parser.add_argument`; the arguments are similar.
  self.OptionParser.add_option("--docwidth", action="store", type="float", dest="docwidth", default=0.0)
prepare.py:25: DeprecationWarning: Effect.OptionParser or `optparse` has been deprecated and replaced with `argparser`.You must change `self.OptionParser.add_option` to `self.arg_parser.add_argument`; the arguments are similar.
  self.OptionParser.add_option("--docheight", action="store", type="float", dest="docheight", default=0.0)
prepare.py:295: DeprecationWarning: Effect.affect is now `Effect.run()`. The `output` argument has changed.
  e.affect()
prepare.py:164: DeprecationWarning: inkex.etree was removed, use "from lxml import etree"
  grid = inkex.etree.Element(inkex.addNS('grid','inkscape'))

What should have happened?

The document should have been prepared without error.

Judging by the warning messages, Svg2Shenzhen is using function calls, which a deprecated in Inkscape 1.0alpha2.

Continue the test with exporting to Kicad

  1. Run svg2shenzhen using the menu Extensions > Svg2Shenzhen SVGSZVER (note the strange name extension) > 2. Export Kicad…
  2. Choose default parameters and click Apply

What happened?

The export file is not getting written to disk, and the extension returns the following warnings and errors:

export.py:224: DeprecationWarning: Effect.OptionParser or `optparse` has been deprecated and replaced with `argparser`.You must change `self.OptionParser.add_option` to `self.arg_parser.add_argument`; the arguments are similar.
  self.OptionParser.add_option("--path", action="store", type="string", dest="path", default="~/", help="")
export.py:225: DeprecationWarning: Effect.OptionParser or `optparse` has been deprecated and replaced with `argparser`.You must change `self.OptionParser.add_option` to `self.arg_parser.add_argument`; the arguments are similar.
  self.OptionParser.add_option('-f', '--filetype', action='store', type='string', dest='filetype', default='jpeg', help='Exported file type')
export.py:226: DeprecationWarning: Effect.OptionParser or `optparse` has been deprecated and replaced with `argparser`.You must change `self.OptionParser.add_option` to `self.arg_parser.add_argument`; the arguments are similar.
  self.OptionParser.add_option("--crop", action="store", type="inkbool", dest="crop", default=False)
export.py:227: DeprecationWarning: Effect.OptionParser or `optparse` has been deprecated and replaced with `argparser`.You must change `self.OptionParser.add_option` to `self.arg_parser.add_argument`; the arguments are similar.
  self.OptionParser.add_option("--dpi", action="store", type="float", dest="dpi", default=600)
export.py:228: DeprecationWarning: Effect.OptionParser or `optparse` has been deprecated and replaced with `argparser`.You must change `self.OptionParser.add_option` to `self.arg_parser.add_argument`; the arguments are similar.
  self.OptionParser.add_option("--threshold", action="store", type="float", dest="threshold", default=128.0)
export.py:229: DeprecationWarning: Effect.OptionParser or `optparse` has been deprecated and replaced with `argparser`.You must change `self.OptionParser.add_option` to `self.arg_parser.add_argument`; the arguments are similar.
  self.OptionParser.add_option("--openfactory", action="store", type="inkbool", dest="openfactory", default="true")
export.py:230: DeprecationWarning: Effect.OptionParser or `optparse` has been deprecated and replaced with `argparser`.You must change `self.OptionParser.add_option` to `self.arg_parser.add_argument`; the arguments are similar.
  self.OptionParser.add_option("--openkicad", action="store", type="inkbool", dest="openkicad", default="true")
export.py:231: DeprecationWarning: Effect.OptionParser or `optparse` has been deprecated and replaced with `argparser`.You must change `self.OptionParser.add_option` to `self.arg_parser.add_argument`; the arguments are similar.
  self.OptionParser.add_option("--autoflatten", action="store", type="inkbool", dest="autoflatten", default="true")
export.py:232: DeprecationWarning: Effect.OptionParser or `optparse` has been deprecated and replaced with `argparser`.You must change `self.OptionParser.add_option` to `self.arg_parser.add_argument`; the arguments are similar.
  self.OptionParser.add_option("--debug", action="store", type="inkbool", dest="debug", default=False)
export.py:736: DeprecationWarning: Effect.affect is now `Effect.run()`. The `output` argument has changed.
  e.affect()
export.py:336: DeprecationWarning: self.args[-1] is now self.options.input_file
  curfile = self.args[-1]
Traceback (most recent call last):
  File "export.py", line 740, in <module>
    _main()
  File "export.py", line 736, in _main
    e.affect()
  File "/Applications/Inkscape.app/Contents/Resources/share/inkscape/extensions/inkex/deprecated.py", line 181, in affect
    return self.run(args=args)
  File "/Applications/Inkscape.app/Contents/Resources/share/inkscape/extensions/inkex/base.py", line 111, in run
    self.save_raw(self.effect())
  File "export.py", line 313, in effect
    self.processExportLayer()
  File "export.py", line 337, in processExportLayer
    layers = self.get_layers(curfile)
  File "export.py", line 537, in get_layers
    if  layer_label_name in self.layer_map.iterkeys():
AttributeError: 'dict' object has no attribute 'iterkeys'

What should have happened?

The Kicad module should have been created without error.

This time there are depreciation warnings, but also errors, which seem to prohibit that Svg2Shenzhen succeeds.

Inkscape Version and Operating System:

  • Inkscape Version: 1.0alpha2 (863a58d, 2019-08-17), official notarized build
  • Operating System version: macOS Mojave 10.14.6 (18G87)

inverting the soldemask layer

It would be great to have a tickbox to choose that the soldermask layer gets inverted. if its a simple hand-drawn style it ok to just duplicate the copper layer and put it in the soldermask, so all area outside of the copper gets masked without inversion.

but if i want to have a dedicated design with the soldermask, best to to be able to draw it as it is and do the inverting behind the scene during export to kicad.

missing chmod +x on linux

following instructions. working with example virusPCB svg
after
4.Extension > Svg2Shenzhen > Export Kicad
i get

  1. png files in output folder (they look fine)
  2. this error popup
    "/home/yair/.config/inkscape/extensions/bitmap2component_linux64" "/home/yair/dev/testPCB/001_F.Cu.png" "/home/yair/dev/testPCB/001_F.Cu.kicad_module" F.Cu true 128 "/home/yair/.config/inkscape/extensions/bitmap2component_linux64" "/home/yair/dev/testPCB/002_F.Mask.png" "/home/yair/dev/testPCB/002_F.Mask.kicad_module" F.Mask true 128 "/home/yair/.config/inkscape/extensions/bitmap2component_linux64" "/home/yair/dev/testPCB/003_F.Silk.png" "/home/yair/dev/testPCB/003_F.Silk.kicad_module" F.Silk true 128 Traceback (most recent call last): File "export_layers.py", line 493, in <module> _main() File "export_layers.py", line 489, in _main e.affect() File "/usr/share/inkscape/extensions/inkex.py", line 283, in affect self.effect() File "export_layers.py", line 228, in effect self.processExportLayer() File "export_layers.py", line 278, in processExportLayer with open(kicad_file, 'r') as myfile: IOError: [Errno 2] No such file or directory: '/home/yair/dev/testPCB/001_F.Cu.kicad_module'

archLinux
Inkscape 0.92.2 2405546, 2018-03-11

zone support

create kicad zone will be good addition for this extension

Unclear in the documentation, please update

The extention contains a CLI version for the png2composant executable. If it is not chmod+x'ed underlinux, any layer that is enabled and relying on a component creation will make the export crash due to the .kicad_mod not existing.

chmod +x 'ing the executable solves the problem but it should be clear in the install doc.

Error on export

I'm in a PCB workshop with the fabulous @morgulbrut. I'm trying to make some #badgelife pcb art (currently mostly black squares).

I can prepare the document (with some deprecation warnings). Then I got an error.
I did switch to python 2.7 like described here.

I did restart Inkscape and then got the following error:

TypeError: can't pickle file objects

export.py:224: DeprecationWarning: Effect.OptionParser or `optparse` has been deprecated and replaced with `argparser`.You must change `self.OptionParser.add_option` to `self.arg_parser.add_argument`; the arguments are similar.
  self.OptionParser.add_option("--path", action="store", type="string", dest="path", default="~/", help="")
export.py:225: DeprecationWarning: Effect.OptionParser or `optparse` has been deprecated and replaced with `argparser`.You must change `self.OptionParser.add_option` to `self.arg_parser.add_argument`; the arguments are similar.
  self.OptionParser.add_option('-f', '--filetype', action='store', type='string', dest='filetype', default='jpeg', help='Exported file type')
export.py:226: DeprecationWarning: Effect.OptionParser or `optparse` has been deprecated and replaced with `argparser`.You must change `self.OptionParser.add_option` to `self.arg_parser.add_argument`; the arguments are similar.
  self.OptionParser.add_option("--crop", action="store", type="inkbool", dest="crop", default=False)
export.py:227: DeprecationWarning: Effect.OptionParser or `optparse` has been deprecated and replaced with `argparser`.You must change `self.OptionParser.add_option` to `self.arg_parser.add_argument`; the arguments are similar.
  self.OptionParser.add_option("--dpi", action="store", type="float", dest="dpi", default=600)
export.py:228: DeprecationWarning: Effect.OptionParser or `optparse` has been deprecated and replaced with `argparser`.You must change `self.OptionParser.add_option` to `self.arg_parser.add_argument`; the arguments are similar.
  self.OptionParser.add_option("--threshold", action="store", type="float", dest="threshold", default=128.0)
export.py:229: DeprecationWarning: Effect.OptionParser or `optparse` has been deprecated and replaced with `argparser`.You must change `self.OptionParser.add_option` to `self.arg_parser.add_argument`; the arguments are similar.
  self.OptionParser.add_option("--openfactory", action="store", type="inkbool", dest="openfactory", default="true")
export.py:230: DeprecationWarning: Effect.OptionParser or `optparse` has been deprecated and replaced with `argparser`.You must change `self.OptionParser.add_option` to `self.arg_parser.add_argument`; the arguments are similar.
  self.OptionParser.add_option("--openkicad", action="store", type="inkbool", dest="openkicad", default="true")
export.py:231: DeprecationWarning: Effect.OptionParser or `optparse` has been deprecated and replaced with `argparser`.You must change `self.OptionParser.add_option` to `self.arg_parser.add_argument`; the arguments are similar.
  self.OptionParser.add_option("--autoflatten", action="store", type="inkbool", dest="autoflatten", default="true")
export.py:232: DeprecationWarning: Effect.OptionParser or `optparse` has been deprecated and replaced with `argparser`.You must change `self.OptionParser.add_option` to `self.arg_parser.add_argument`; the arguments are similar.
  self.OptionParser.add_option("--debug", action="store", type="inkbool", dest="debug", default=False)
export.py:748: DeprecationWarning: Effect.affect is now `Effect.run()`. The `output` argument has changed.
  e.affect()
export.py:347: DeprecationWarning: self.args[-1] is now self.options.input_file
  curfile = self.args[-1]
Traceback (most recent call last):
  File "export.py", line 752, in <module>
    _main()
  File "export.py", line 748, in _main
    e.affect()
  File "/Applications/Inkscape.app/Contents/Resources/share/inkscape/extensions/inkex/deprecated.py", line 181, in affect
    return self.run(args=args)
  File "/Applications/Inkscape.app/Contents/Resources/share/inkscape/extensions/inkex/base.py", line 114, in run
    self.save_raw(self.effect())
  File "export.py", line 324, in effect
    self.processExportLayer()
  File "export.py", line 397, in processExportLayer
    pickle.dump(options, f)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pickle.py", line 1376, in dump
    Pickler(file, protocol).dump(obj)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pickle.py", line 224, in dump
    self.save(obj)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pickle.py", line 331, in save
    self.save_reduce(obj=obj, *rv)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pickle.py", line 425, in save_reduce
    save(state)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pickle.py", line 286, in save
    f(self, obj) # Call unbound method with explicit self
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pickle.py", line 655, in save_dict
    self._batch_setitems(obj.iteritems())
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pickle.py", line 669, in _batch_setitems
    save(v)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pickle.py", line 306, in save
    rv = reduce(self.proto)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy_reg.py", line 70, in _reduce_ex
    raise TypeError, "can't pickle %s objects" % base.__name__
TypeError: can't pickle file objects

Prepare document gives lxml dependency error (Windows).

Hello,

I am using Windows 7 with Inkscape 0.92.4 and svg2shenzhen 0.2.16. When running prepare document, I'm getting an error that the "...lmxml wrapper for libxml2 is required...". I ran an administrator command prompt and ran "pip install lxml". The install finishes successfully. I close Inkscape and reopen and run prepare document again... I get the same dependency error. If I go back to the windows command prompt and run the "pip install lxml" command again, it says that the "requirement already satisfied". So then the question is how to get around this dependency error?

The other issues similar do not seem to have a specific resolution for this dependency error after the dependency is installed via pip. Thanks,

KiCad 5 anchor pad support

Noticed this in @Junes-PhD's kicad_arbitrary_pad_example. I missed the Hackchat but it looks like KiCad 5 will support funky pad shapes which means you can better make drawings part of the circuit without breaking the rules checks. This won't work with KiCad 4 of course.
image

  (pad 1 smd custom (at 0 0) (size 0.001 0.001) (layers F.Cu F.Paste F.Mask)
    (zone_connect 0)
    (options (clearance outline) (anchor rect))
    (primitives
      (gr_poly (pts
         (xy -12.942245 10.707266) (xy -12.253724 11.874456) (xy -11.425987 13.074738) (xy -10.645207 14.040135) (xy -9.361396 15.444829)
         (xy -11.699119 17.536869) (xy -12.619469 18.358458) (xy -13.382433 19.035699) (xy -13.906951 19.496904) (xy -14.111184 19.670024)
         (xy -14.162957 19.935938) (xy -14.225695 20.590957) (xy -14.28255 21.439588) (xy -14.639823 23.402138) (xy -15.43931 25.1571)
         (xy -16.617038 26.643019) (xy -18.109037 27.79844) (xy -19.851333 28.561908) (xy -21.779955 28.871969) (xy -22.023363 28.875789)
         (xy -22.857384 28.840815) (xy -23.460461 28.751177) (xy -23.63843 28.676657) (xy -23.531601 28.430362) (xy -23.094161 27.905675)
         (xy -22.395586 27.178997) (xy -21.505349 26.326727) (xy -21.481343 26.304569) (xy -19.125125 24.131612) (xy -20.725194 22.337724)
         (xy -21.619116 21.334803) (xy -22.537778 20.302963) (xy -23.308394 19.4363) (xy -23.431939 19.297174) (xy -24.538614 18.050513)
         (xy -26.506676 19.768703) (xy -27.4354 20.579181) (xy -28.280475 21.316071) (xy -28.914224 21.868069) (xy -29.111737 22.039762)
         (xy -29.748738 22.592631) (xy -29.612724 20.816598) (xy -29.217555 18.763899) (xy -28.39627 17.004342) (xy -27.192862 15.576228)
         (xy -25.651325 14.517862) (xy -23.81565 13.867548) (xy -21.729831 13.663588) (xy -21.408508 13.673374) (xy -19.56924 13.758343)
         (xy -17.337778 11.775775) (xy -16.371865 10.917968) (xy -15.500868 10.145121) (xy -14.834812 9.554823) (xy -14.530894 9.286149)
         (xy -13.955472 8.779092) (xy -12.942245 10.707266)) (width 0))
    ))

0.2.13 Plugin No Longer Runs

The zip file, "svg2shenzhen-extension.zip" that makes up release 0.2.13 contains the following code in "export.py":

    def processExportLayer(self):
        insertion_date = dateutil.parser.parse('2018-07-28 14:25:30')
        time_between_insertion = datetime.now() - insertion_date

        if (time_between_insertion.days>7):
            return

This now means the plugin doesn't run. Was this planned obsolescence?

Different solder mask clearance?

I need to produce a "shine-through" PCB (text with LEDs behind). I can put an exact duplicate of my text on the F.Cu and F.Mask layers but the letters on the Mask will always be "bigger" (i.e. some solder mask clearance is auto-added). Changing the solder mask clearance in PCBnew afterwards doesn’t help.

The PCB looks really awful with the copper layer "bleeding" into the letters …

Is there any trick or workaround to get a zero solder mask clearance?

exception in simplepath.py

Hi, I have just installed the extension and I'm getting the following error:

Traceback (most recent call last):
File "prepare.py", line 11, in
import simplepath, simpletransform
File "/usr/share/inkscape/extensions/simplepath.py", line 51
raise Exception, 'Invalid path data!'
^
SyntaxError: invalid syntax

This is on Fedora31 with Inkscape 0.92

bitmap2component is not buildable

It is not possible to build bitmap2component with the shell scripts or cmake files provided with the source code.

It looks like the cmake files were taken directly from the KiCad source code, but they require a lot more build infrastructure and dependencies to compile cleanly.

When running src/build.sh, the following error is shown:

../common/geometry/hetriang.cpp:50:10: fatal error: class_board_connected_item.h: No such file or directory
 #include <class_board_connected_item.h>
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

It's also unclear which version of KiCad these sources are based on.

Would it be possible to use the bitmap2component executable that is provided with KiCad instead? This would make it much easier to package svg2shenzhen without relying on precompiled binaries.

On Linux, distribution packages would install it to/usr/bin/bitmap2component (or another other location on $PATH). On OSX, the binary is in /Applications/KiCad/KiCad/kicad.app/Contents/Applications/bitmap2component.app/Contents/MacOS/bitmap2component. I don't know the exact location on Windows.

Alternatively, there's also this project: https://github.com/mtl/svg2mod
Converting vector graphics directly to outlines is cleaner than with an intermediate image step, and it would be possible to do everything in Python.

prepare document now allows non square size

hi @kasbah im pushing new update, this is a bug from the beginning and finally i managed to fix it, need to compile bitmap2component to all platform again (i hate it) i'll do it when i have more free time..

Allow *.Cu and *.Mask layers

Could be a handy shortcut for adding copper and mask to both sides. I think for kicad_mod output we can even use the *.Cu and *.Mask names to get the effect. Not sure on kicad_pcb output.

Bitmap2component compilation fails at first step

$ g++ -c ../common/geometry/* -lpotrace -L. -L../potrace -I../include -I../polygon -I../potrace -I.  -std=c++11 
../common/geometry/hetriang.cpp:50:40: fatal error: class_board_connected_item.h: No such file or directory
compilation terminated

Error when attempting to export to Kicad

The error occurs when clicking "Apply" on the "2. Export Kicad" window when exporting as a "KICAD - Module":

Traceback (most recent call last): File "export.py", line 752, in <module> _main() File "export.py", line 748, in _main e.affect() File "C:\Program Files\Inkscape\share\extensions/inkex.py", line 283, in affect self.effect() File "export.py", line 322, in effect self.setInkscapeScaling() File "export.py", line 286, in setInkscapeScaling viewbox = root.attrib['viewBox'].split(' ') File "src/lxml/etree.pyx", line 2455, in lxml.etree._Attrib.__getitem__ KeyError: 'viewBox'

I am unsure how to proceed, please advise.

Checkbox to hide Val and Ref

I was wondering if it might be possible to add a checkbox to set the Value and Reference text to "not visible" from the Step 2 Menu within Inkscape?

Unable to export .Mask (MacOS)

First of all, thanks for this great Inkscape addon!

I am playing around with it since a few days and it works great for exporting F.Cu and Edge.Cuts but I run into problems when I wanted to include a F.Mask layer.

I renamed the layer and used a copy of my F.Cu drawing and also tried F.Mask-auto but neither works for me. It seems like only F.Cu and Edge.Cuts always are exported. I still have to check if F.Silk works because then I could do the texteditor rename workaround.

I am not sure if it's a OS problem but Inkscape does not run as smoothly on MacOS as it does on Linux/Windows (from my experience). Here are all my files

Not creating files in Windows

Attempting to run the Export command gives errors:

"C:\Users\username\AppData\Roaming\inkscape\extensions\bitmap2component.exe" "C:\Users\username\test\images\001_F.Cu.png" "C:\Users\username\test\pcbart.pretty\001_F.Cu.kicad_mod" F.Cu true 600 128 "C:\Users\username\AppData\Roaming\inkscape\extensions\bitmap2component.exe" "C:\Users\username\test\images\002_F.Mask.png" "C:\Users\username\test\pcbart.pretty\002_F.Mask.kicad_mod" F.Mask true 600 128 "C:\Users\username\AppData\Roaming\inkscape\extensions\bitmap2component.exe" "C:\Users\username\test\images\003_F.Silk.png" "C:\Users\username\test\pcbart.pretty\003_F.Silk.kicad_mod" F.Silk true 600 128 Traceback (most recent call last): File "export_layers.py", line 671, in <module> _main() File "export_layers.py", line 667, in _main e.affect() File "C:\Program Files\Inkscape\share\extensions/inkex.py", line 283, in affect self.effect() File "export_layers.py", line 311, in effect self.processExportLayer() File "export_layers.py", line 382, in processExportLayer with open(kicad_file, 'r') as myfile: IOError: [Errno 2] No such file or directory: 'C:\\Users\\username\\test\\pcbart.pretty\\001_F.Cu.kicad_mod'

Even if I manually create the directory it's looking for it won't create the files. It appears to work fine when done in Ubuntu.

Edge.Cut layer loses quality when exported to Kicad

Hi,

I noticed that beziers won't be converted to the Edge.Cut layer,
When I checked the option Auto flatten bezier for Edge.Cut layer it works- but not 100% same shape.

My manual workaround is to save the Edge.Cut layer as edge.dxf file from inkscape-
And on Kicad File -> Import -> Graphics -> edge.dxf and place it instad of the generated Edge.Cut layer..

It takes a lot of time and have to be done every time...
Any chance we can make it automatic?

Thanks,
Arad

Increase maximum dpi export

I tried to modify

<param name="dpi" type="int" min="0" max="2000" _gui-text="Export DPI (default: 600)">600</param>

to

<param name="dpi" type="int" min="0" max="10000" _gui-text="Export DPI (default: 600)">600</param>

and the export was super fine.
Is there any reason to limit the dpi to 2000?
I see it is quite impossible to manufacture a pcb with higher resolution, but for some niche application it might be ok to have a higher limit.
I tried to go over 10000, but the number of lines in the footprint didn't change, so maybe the upper limit is 10000.

Create drc compliant custom shaped pads

I noticed that if I take the connected shapes (as defined in topology: https://en.wikipedia.org/wiki/Connected_space) and place a small smd pad inside each of them, then select both the shape and the pad, I can right click and convert them to a custom shaped pad.
This results in a fully DRC compliant shape.

Do you think to be possible to avoid this additional step and to do it directly inside svg2shenzen?
For example when the layer is set as Cu.

See for example:
https://pacinispace.blogspot.com/2017/02/gerber-to-kicadmod.html
https://forum.kicad.info/t/custom-footprints-scripting-using-custom-shape-primitives/19538

Edge cut scaling and board outline

I have an svg file created up using Inkscape 0.92.4 on Windows and the 0.2.17 release of svg2shenzhen. The export process appears to complete as expected but the resulting Kicad pcb has the edge cuts scaled approximately four times larger than it should be, and offset from the silk and mask renders. The mask and silk layers appear to be scaled correctly.
Luna.zip
image
Kicad version 5.1.4
image

I am unable to view the 3D render of the board. Kicad throws an error that it "Cannot determine the board outline"

I don't have any other versions of Inkscape or Kicad to test this at the moment. Attached are the svg as well as the outputs from svg2shenzhen.

miss libxml2 [mac]

I try to install it by "brew install libxml2" but does not works anyway.

The fantastic lxml wrapper for libxml2 is required by inkex.py and therefore this extension.Please download and install the latest version from http://cheeseshop.python.org/pypi/lxml/, or install it through your package manager by a command like: sudo apt-get install python-lxml

Technical details:
No module named lxml

Doesn't work under 0.92.4 on Lubuntu 19.04

Fails during export with a No such file or directory: <export_path>/.svg2shenzhen-cache/drawing.pretty/F.Cu_g19.kicad_mod

Where <export_path> is the path the user specified as the export location.

This is svg2shenzhen version 0.2.17 from the pre-compiled zip file.

Someone else was having a different issue with this version of kicad on macOS in issue #44. Unfortunately 0.92.4 is the version of Kicad in the Lubuntu/Ubuntu 19.04 apt repository.

Drill holes not showing up

Trying to export my design but holes not appearing as non plated through holes (no holes appearing at all). I have to physically place them in kicad. Also, would like a way for plated holes to be automatically placed.

Heres a link to the SVG

file:///C:/InkscapePCBDrawings/Ralley.svg

Fix file permission on Linux and directly install using git

Similarly to #2 , the latest version is still not working because of a missing executable bit
chmod +x ~/.config/inkscape/extensions/bitmap2component_linux64

Traceback (most recent call last):
  File "export.py", line 752, in <module>
    _main()
  File "export.py", line 748, in _main
    e.affect()
  File "/usr/share/inkscape/extensions/inkex.py", line 283, in affect
    self.effect()
  File "export.py", line 324, in effect
    self.processExportLayer()
  File "export.py", line 490, in processExportLayer
    with open(kicad_file, 'r') as f:
IOError: [Errno 2] No such file or directory: '/tmp/.svg2shenzhen-cache/customshapekicad.pretty/F.Cu_g824.kicad_mod'

I think it is because of the zip archive. A tar.gz should maintain the proper permissions.
Can you add this to the install instructions?

On a side note, is it possible to install this plugin using directly the git repo?
All my freecad and kicad plugins are installed in this way and I wonder if I can do the same using svg2shenzen and inkscape.

Thanks for the amazing tool!

Use variables in output path

Instead of setting output path to a folder ~/output we could set it to the exact filename ~/output/my.kicad_pcb but also allow a filename variable to be substituted.

E.g. ~/output/{filename} could expand to:

  • ~/output/drawing.kicad_pcb if the svg is called drawing.svg and the output is set to kicad_pcb (it would still also create a drawing.pro and fp-lib-table)
  • ~/output/edge_conector.kicad_mod if the svg is called edge_connector.svg and the output filetype is set to kicad_mod

If the output is set to folder we could use the old behaviour. Thoughts?

via annular ring

reproduce:

  • create a (0.6mm) circle in drill layer
  • a 1mm copr ring around it is generated automatically in copper layer.

this is contrary to the TIPS section in readme

For Drill layers, place circle objects and they will be converted into drill pads in KiCad with the same diameter. These drills will not have annular rings unless you also add copper to the F.Cu and B.Cu layers. Don't use any groups on Drill layers either.

to combat this i erase the ring in gerbv (gerbv is awesome)

Exports empty file in Linux

Running Ubuntu
Downloaded latest version from Releases

The help screen does not show the version, it shows SVGSZ_VER
All layers are 'disabled' except Edge.Cuts and F.Cu
I fixed the permissions on bitmap2component_linux64
The .kicad_pcb is created but there are no layers in there

[edit]
In Windows it works right away.
Unfortunatly the resulting PCB file does not render with message "cannot determine the board outline".
This message is caused by an enormous amount of not-so-good connected points in the design. When using an SVG with a few points it works.

(kicad_pcb (version 4) (host pcbnew 4.0.7)

	(general
		(links 0)
		(no_connects 0)
		(area 77.052499 41.877835 92.193313 53.630501)
		(thickness 1.6)
		(drawings 8)
		(tracks 0)
		(zones 0)
		(modules 1)
		(nets 1)
	)

	(page A4)
	(layers
		(0 F.Cu signal)
		(31 B.Cu signal)
		(32 B.Adhes user)
		(33 F.Adhes user)
		(34 B.Paste user)
		(35 F.Paste user)
		(36 B.SilkS user)
		(37 F.SilkS user)
		(38 B.Mask user)
		(39 F.Mask user)
		(40 Dwgs.User user)
		(41 Cmts.User user)
		(42 Eco1.User user)
		(43 Eco2.User user)
		(44 Edge.Cuts user)
		(45 Margin user)
		(46 B.CrtYd user)
		(47 F.CrtYd user)
		(48 B.Fab user)
		(49 F.Fab user)
	)

	(setup
		(last_trace_width 0.25)
		(trace_clearance 0.2)
		(zone_clearance 0.508)
		(zone_45_only no)
		(trace_min 0.2)
		(segment_width 0.2)
		(edge_width 0.15)
		(via_size 0.6)
		(via_drill 0.4)
		(via_min_size 0.4)
		(via_min_drill 0.3)
		(uvia_size 0.3)
		(uvia_drill 0.1)
		(uvias_allowed no)
		(uvia_min_size 0.2)
		(uvia_min_drill 0.1)
		(pcb_text_width 0.3)
		(pcb_text_size 1.5 1.5)
		(mod_edge_width 0.15)
		(mod_text_size 1 1)
		(mod_text_width 0.15)
		(pad_size 1.524 1.524)
		(pad_drill 0.762)
		(pad_to_mask_clearance 0.2)
		(aux_axis_origin 0 0)
		(visible_elements FFFFFF7F)
		(pcbplotparams
			(layerselection 0x010f0_80000001)
			(usegerberextensions false)
			(excludeedgelayer true)
			(linewidth 0.100000)
			(plotframeref false)
			(viasonmask false)
			(mode 1)
			(useauxorigin false)
			(hpglpennumber 1)
			(hpglpenspeed 20)
			(hpglpendiameter 15)
			(hpglpenoverlay 2)
			(psnegative false)
			(psa4output false)
			(plotreference true)
			(plotvalue true)
			(plotinvisibletext false)
			(padsonsilk false)
			(subtractmaskfromsilk false)
			(outputformat 1)
			(mirror false)
			(drillshape 1)
			(scaleselection 1)
			(outputdirectory gerbers/))
	)

	(net 0 "")

	(net_class Default "This is the default net class."
		(clearance 0.2)
		(trace_width 0.25)
		(via_dia 0.6)
		(via_drill 0.4)
		(uvia_dia 0.3)
		(uvia_drill 0.1)
	)
(module LOGO (layer F.Cu)
  (at 0 0)
 (fp_text reference "G***" (at 0 0) (layer F.SilkS) hide
  (effects (font (thickness 0.3)))
  )
  (fp_text value "LOGO" (at 0.75 0) (layer F.SilkS) hide
  (effects (font (thickness 0.3)))
  )
)

)

/tmp/ is not normally writable on linux

I set the temporary "cache" directory to /tmp/ when the svg hasn't been saved yet. This isn't normally writable by the user so it results in asking for a root password.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.