3

In the Inkscape GUI, there is this awesome feature, that lets me 'save as -> file type -> layers as individual SVGs' (the last one at the bottom). Is there any way of doing the same thing from the CLI?

What I have so far:

inkscape -z -l output.svg input.dxf

This converts the 'input.dxf' to 'output.svg', but I can't find the layers within this SVG.

Christoph Bühler
  • 2,795
  • 2
  • 28
  • 43

1 Answers1

2

With help of the Inkscape community (special thanks to @rindolf), I could come up with a solution.

Prerequisites

  • Python 2.7 (It won't work on newer versions)
  • lxml ("pip install lxml")

Adjust Inkscape

Change 'GROUP = "{http://www.w3.org/2000/svg}g"' on line 36 of "tar_layers.py" in "Inkscape\share\extensions" to 'GROUP = "g"'. This has to be done, because your layers won't have that namespace.

Convert the DXF to multiple SVGs (one per layer)

  1. Create an Inkscape SVG from the DXF:

    python share/extensions/dxf_input.py input.dxf > output.svg

  2. Export the layers as individual SVGs inside a tar:

    python share/extensions/tar_layers.py output.svg > output.tar

Now, you should have a 'output.tar' file with Inkscape SVGs inside of it. If you need regular SVG, you have to export them like this:

inkscape -z -l output.svg input.svg

More information about the Inkscape CLI.

Christoph Bühler
  • 2,795
  • 2
  • 28
  • 43