There didn't seem to be a good way to get vector graphics into Pcbnew, so I wrote a small utility that uses an existing SVG library to read files, and then writes them out as KiCad modules. It seemed generally useful so I put it on github. It should let you make something like this:
From a source file like this:
The tool can scale images by a factor that you provide, and will automatically generate a reversed module for use on the back side of a PCB.
As mentioned on komar's techblog, it's advisable to create a solder mask negative region slightly larger than your artwork to account for process imprecision during fabrication.
A few things to note.. I don't really understand how the various parts of KiCad interpret polygons, and sometimes Inkscape will save an image in a way that the conversion process doesn't handle correctly. YMMV. Also, although support is underway for .kicad_mod (pretty) format, it hasn't been tested yet.
SVG graphics in KiCad (svg2mod)
-
- Location: Stockhom, Sweden
- Main keyboard: Symmetric Stagger Board
- Main mouse: Kinzu
- Favorite switch: Topre
- DT Pro Member: -
This is great =)
I just tested with the DT logo example in the pretty format (cause that is the good shit). It doesn't seem to add the layer tags, (layer B.Cu) and so on, to the polygon items. At least not for me, but I may be doing it wrong.. I edited the kicad_mod file by hand to add layers, and all polygons are correct otherwise.
Polygons also have a (width "number"). Setting width to 0 ends you up with the polygon you probably wanted. Setting it to some value x also draws a line segment centred on the polygon segment with a width of x. ( And they plot with that
thickness to the gerber output. I nagged on the kicad launchpad site to have them make it that way =D
(Edit: Had a look and the logo gets a bit mangled when there is no width tag at all. The width of the outline segments is set to some default value, which screws everything up..)
You also can't have more than one footprint in a kicad_mod file. Only the first one is read. Anything after the first (module...) block is ignored.
If you generate the image on the back of the board it will (probably) be mirrored to what you'd want when submitting the gerbers to your manufacturer.. Moving a footprint to the back of the board is a simple matter of flipping it in PCBnew. This changes all layers from back to front and the other way around. Mirroring an svg should probably be done with a negative scaling factor instead.
(Edit: I see now that the footprint on the back layer is mirrored compared to the front one when generated. Though I still say only a front one is ever needed.)
Today I did learn about the (descr ) and (tags ) tags though. I used to add comments to my own footprints after the module block. Thank you for this new piece of information =)
I just tested with the DT logo example in the pretty format (cause that is the good shit). It doesn't seem to add the layer tags, (layer B.Cu) and so on, to the polygon items. At least not for me, but I may be doing it wrong.. I edited the kicad_mod file by hand to add layers, and all polygons are correct otherwise.
Polygons also have a (width "number"). Setting width to 0 ends you up with the polygon you probably wanted. Setting it to some value x also draws a line segment centred on the polygon segment with a width of x. ( And they plot with that
thickness to the gerber output. I nagged on the kicad launchpad site to have them make it that way =D
(Edit: Had a look and the logo gets a bit mangled when there is no width tag at all. The width of the outline segments is set to some default value, which screws everything up..)
You also can't have more than one footprint in a kicad_mod file. Only the first one is read. Anything after the first (module...) block is ignored.
If you generate the image on the back of the board it will (probably) be mirrored to what you'd want when submitting the gerbers to your manufacturer.. Moving a footprint to the back of the board is a simple matter of flipping it in PCBnew. This changes all layers from back to front and the other way around. Mirroring an svg should probably be done with a negative scaling factor instead.
(Edit: I see now that the footprint on the back layer is mirrored compared to the front one when generated. Though I still say only a front one is ever needed.)
Today I did learn about the (descr ) and (tags ) tags though. I used to add comments to my own footprints after the module block. Thank you for this new piece of information =)
-
- Location: USA
- Main keyboard: Custom
- Main mouse: IBM TrackPoint IV
- Favorite switch: Cherry MX Clicky
- DT Pro Member: -
bpiphany.. Thanks for all the great advice (and debugging) on the pretty format! I started writing the code but then realized the version of KiCad I have on Linux is pretty old and will only read the legacy format. I've committed the following changes based on your suggestions:
- Fixed missing (layer ) tags
- Set the polygon (width ) tags, including 0 for polys without an outline, and using the this width tag and (fp_poly ) to draw polygons which have both a fill and outline. For outline-only polygons, it still uses (fp_line )s.
- Only one footprint is now written to the .kicad_mod file.
- Mirroring is still optional for the legacy format. At least in my old version of KiCad (2013-may-18), flipping in Pcbnew does not mirror the footprint, so a mirrored back module is needed. Though I see your point that having a separate x-axis scale factor option would do the trick, and simplify the code. I'll try to make that change next.
-
- Location: Stockhom, Sweden
- Main keyboard: Symmetric Stagger Board
- Main mouse: Kinzu
- Favorite switch: Topre
- DT Pro Member: -
I'm only glad to help. There is a PPA with daily build of KiCAD here https://code.launchpad.net/~js-reynaud/ ... /ppa-kicad I'm currently using that. There was a period of time when there wasn't a PPA, and I had to compile myself. And there was often some sort of trouble with that =P KiCAD has become a lot better. I don't know which version they are up to in legacy, but the new file formats are a jay to work with compared to the old... Also the program seems to crash much less often =)
Polygons are always filled, I think.. It would be great with a non filled version. Writing a separate item for each segment feels a bit unnecessary. fp_poly is actually also always closed. You don't need to specify the first point again at the end.
Ah, yes mirroring of course requires different x- and y-factors. I may have been a bit tired last night.
Polygons are always filled, I think.. It would be great with a non filled version. Writing a separate item for each segment feels a bit unnecessary. fp_poly is actually also always closed. You don't need to specify the first point again at the end.
Ah, yes mirroring of course requires different x- and y-factors. I may have been a bit tired last night.
-
- Location: USA
- Main keyboard: Custom
- Main mouse: IBM TrackPoint IV
- Favorite switch: Cherry MX Clicky
- DT Pro Member: -
A nicely done article on Hackaday by Nava Whiteford highlights some inspiring PCB designs and projects, with an example using svg2mod.
-
- Location: USA
- Main keyboard: Custom
- Main mouse: IBM TrackPoint IV
- Favorite switch: Cherry MX Clicky
- DT Pro Member: -
-
- Main keyboard: Black Widow Ultimate Mac
- Main mouse: Naga Epic
- Favorite switch: Cherry MX Green
- DT Pro Member: -
I'm having an issue.
The resulting output is blank except for the name 'svg2mod G***".
Code: Select all
$ ./svg2mod.py -i ../keyboard-layout-outline.svg -o ../keyboard.mod
Parsing SVG...
No handler for element {http://www.w3.org/2000/svg}metadata
No handler for element {http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd}namedview
No handler for element {http://www.w3.org/2000/svg}style
No handler for element {http://www.w3.org/2000/svg}defs
Writing module file: ../keyboard.mod