Importing SVG into layout (silk, board's edge, etc.)

I’m trying to import a design in SVG that contains only lines into my layout, using KiCAD 5.1 on Ubuntu 18.04.

I see that the footprint editor has menu option File → Import Outlines from DXF or SVG File..., but I select that menu and nothing happens (as in: literally, nothing happens other than the menu closes — no dialog opens, nothing happens inside the footprint editor or anywhere else on my desktop). I restarted KiCAD; no changes.

Do I need some sort of plugin installed or enabled? Any alternative ways to get this done?

Thanks!

Did you “Create new Footprint…” before invoking this menu ? On Windows, it displays the usual file selection dialog.

I had not — that seems to be required.

It still does not work: now I get the dialog, and when I select the SVG I want to import, it tells me There is no plugin to handle this file type.

I forget now (and can’t seem to figure out) how to install plugins — I know I installed the “BOM group by” plugin (that was when using version 5.0, and the plugin is still enabled after I upgraded to 5.1). Any help with this?

Thanks

Alternatively — can you suggest an easy way to turn an SVG file into a sequence of short segments (the coordinates)?

I have no problem in writing a quick little program to format those coordinates as below and then copy-n-paste into the .kicad_pcb file with a text editor:

  (gr_line (start 50.85 42.675) (end 50.175 41.5) (layer F.SilkS) (width 0.15))

(or even easier, just import the coordinates and then do a regexp search-and-replace)

Why not use the inkscape extension svg2shenzen https://github.com/badgeek/svg2shenzhen

1 Like

Any chance it would be available through the Ubuntu repositories? Or in some form that is reasonably feasible to make it work? (I downloaded directly from github, and every single command I try — ./build.sh, or make or cmake — just gives me a dozen-screens worth of error messages! :-\

inkscape is in the repos. the extension is to be installed as any other inkscape plugin. (read the inkscape documentation for help with that.) Or you know the install part of the readme file.

You could also use the standalone tool svg2mod: https://github.com/mtl/svg2mod

In 5.1, SVG import is an advanced config option and is not formally supported yet. To enable it, see the instructions here: https://bugs.launchpad.net/kicad/+bug/1821571

*sigh* :frowning: … I seem to be Python-impaired!! (actually, the statement is valid without the “seem to” part) And I guess to be fair, it does seem like the tools assume familiarity with basic (or advanced?) Python usage — maybe installing a module is something that is “obvious” in that any normal Python user/programmer would obviously know…

Me, I see the error:

  File "./setup.py", line 4, in <module>
    import setuptools
ImportError: No module named setuptools

And that’s it: end of the road as far as I’m concerned / able… :frowning:

I guess I’ll try the inkscape plugin (I’ve never used inkscape either, but I’ll give it a try anyway!)

cal-linux
Don’t think of yourself as python impaired. Nobody is proficient in every technology ever created.
But do use the vast pool of information already created and freely available on the internet.
Literally first google result for “no module named setuptools” leads to a solution

I personally only ask for help when a questioned can not be formulated easily for google to find relevant result or the problem is so niche that nobody really has encountered it before or at least bothered to post a solution online. 99% of issues are not in that category and can be helped by a quick search.

1 Like

Hahaha — good point; and to be honest, yes, three minutes after sending my last reply, I figured that rather than “end of the road”, it would normally be more like “ok, next item to Google search” … I guess I’ve been running a little shorter-than-normal in patience today   :laughing:

It works in latest nightlies. I can’t say if it does in v5.1 (need to check). Can you use a nightly build?

Tom

You should know better than to just suggest the use of nightlies without even mentioning that this comes with certain risks. (loss of guaranteed compatibility with previous versions, higher number of bugs, little to no documentation of changes to the interface, …)

@cal-linux before switching to nightly i suggest you really read this: Is it a good idea to use a nightly build version?

Oh yes!! I mean, no, I have not read that link you sent, because in principle I don’t need to (I already know that!).

I’m not trying to sound obnoxious/arrogant: I’m just trying to say that yes, I’m 100% with you — I’m using KiCAD for actual work (it’s research, and not necessarily commercial-quality stuff that will make it to the shelves; but still, I need to rely on the higher level of dependability that official releases offer).

With that said — Tom’s suggestion makes sense in that I could just set up a quick virtual machine, use the nightly to do the operation that the official 5.1 does not offer, and then export the result and continue using it with 5.1 (but you are right, that he should accompany that advice with the disclaimer/warning about the involved risks).

BTW, at this point in time, I just accomplished what I needed to do just by hacking/reverse-engineering the thing. Turns out that LibreOffice Draw allows me to convert an outline that containes segments and Bezier curves into a polygon (i.e., exclusively segment lines, getting short in length whenever the curvature is steeper). I saved as SVG, and when I opened the SVG in a text editor, it could not be more obvious what I was looking at. After copy-n-pasting the coordinates and removing the commas, this quick program output the bunch of lines that I just had to paste into the .kicad_pcb file:

// Author: Cal-linux
// Crapware 1.0 License:  In the extremely unlikely event that you may find this useful, 
// you may use it 100% at your own risk.  ABSOLUTELY NO GUARANTEES AND NO 
// LIABILITY ON MY SIDE.

#include <iostream>
using namespace std;

int main ()
{
    double x, y, x_prev, y_prev;

    cin >> x_prev >> y_prev;
    while (cin >> x >> y)
    {
        cout << "  (gr_line (start " << (x_prev/100) << ' ' << (y_prev/100)
            << ") (end " << (x/100) << ' ' << (y/100)
            << ") (layer F.SilkS) (width 0.25))" << endl;

        x_prev = x;
        y_prev = y;
    }

    return 0;
}

I’m only suggesting Cal-Linux can use the nightly build to import an SVG into a footprint. He can then save the footprint and continue editing it using v5.1.

Tom

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.