在Inkscape CLI中将DXF转换为SVG,同时保留图层 [英] Convert DXF to SVG in Inkscape CLI while keeping layers

查看:417
本文介绍了在Inkscape CLI中将DXF转换为SVG,同时保留图层的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Inkscape GUI中,有一个很棒的功能,让我 另存为->文件类型->图层作为单独的SVG"(最后一个位于底部).通过CLI,有什么方法可以做同样的事情?

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

这会将'input.dxf'转换为'output.svg',但是我找不到此SVG中的图层.

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

推荐答案

在Inkscape社区的帮助下(特别感谢@rindolf),我可以提出一个解决方案.

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

先决条件

  • Python 2.7(在较新版本上不起作用)
  • lxml("pip install lxml")

调整Inkscape

更改'GROUP ="{ http://www.w3.org/2000/svg"g",位于" Inkscape \ share \ extensions中的" tar_layers.py的第36行上,为" GROUP ="g".必须这样做,因为您的图层将没有该名称空间.

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.

将DXF转换为多个SVG(每层一个)

  1. 从DXF创建Inkscape SVG:

  1. Create an Inkscape SVG from the DXF:

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

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

将图层导出为tar中的单个SVG:

Export the layers as individual SVGs inside a tar:

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

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

现在,您应该拥有一个带有Inkscape SVG的"output.tar"文件.如果您需要常规的SVG,则必须这样导出它们:

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

有关 Inkscape CLI 的详细信息.

这篇关于在Inkscape CLI中将DXF转换为SVG,同时保留图层的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆