Convert DXF to SVG in Inkscape CLI while keeping layers

心不动则不痛 提交于 2019-12-06 03:32:04

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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!