Svg2librepcb: CLI tool and Inkscape extension

Hi all. To convert SVG files (e.g. a logo) to a LibrePCB library element, I wrote a small tool called “svg2librepcb”:

It also contains an Inkscape extension to simplify the workflow:

It’s still very rough around the edges, but can already be used to import arbitrary shapes into LibrePCB.

2 Likes

All the shapes are coming out far too big. Is there a way to scale them?

The dimensions in the SVG are used directly for the LibrePCB components. You will have to scale the elements in the SVG before conversion.

I’m not even sure if SVG has support for reference units. When saving an Inkscape SVG, the following element is inserted:

<sodipodi:namedview
  ...
  inkscape:document-units="mm"

…however, when exporting a “Plain SVG”, that tag is gone.

One option would be to add a “treat SVG units as mm” option in the exporter. Pull requests would be welcome.

Another option would be a set off input fields for the bounding box target size. This way, an object could be re-scaled.

I’ve been going about making some of my own tools to modify and scale the librepcb packages (graphics), how have you been generating the footprint and polygon ids? I don’t know if there’s a way I can do it so it doesn’t conflict with the footprint or polygon ids for other packages, but I also don’t know if it matters.

@pknessness these IDs are simply random UUIDs: svg2librepcb/src/main.rs at d80c8f5ca00c419bb21a8d00e9180cbac9f2f0ca · dbrgn/svg2librepcb · GitHub