svg - 在保留图层的同时在 Inkscape CLI 中将 DXF 转换为 SVG

标签 svg inkscape dxf

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

我目前拥有的:

inkscape -z -l output.svg input.dxf

这会将“input.dxf”转换为“output.svg”,但我无法在该 SVG 中找到图层。

最佳答案

在 Inkscape 社区的帮助下(特别感谢@rindolf),我想出了一个解决方案。

先决条件

  • Python 2.7(不适用于较新的版本)
  • lxml ("pip install lxml")

调整 Inkscape

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

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

  1. 从 DXF 创建 Inkscape SVG:

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

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

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

现在,您应该有一个“output.tar”文件,其中包含 Inkscape SVG。如果您需要常规 SVG,则必须像这样导出它们:

inkscape -z -l output.svg input.svg

关于 the Inkscape CLI 的更多信息.

关于svg - 在保留图层的同时在 Inkscape CLI 中将 DXF 转换为 SVG,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36719846/

相关文章:

unix - 用于选择对象/路径的 Inkscape CLI 语法

javascript - 将 B 样条曲线转换为贝塞尔曲线

javascript - 如何在 d3 javascript 中为 SVG 文本元素分配唯一 ID

javascript - 为什么在 Chrome 中 SVG 路径的笔画中会出现一些间隙,而在 Firefox 中却没有?

ios - 在 Inkscape 中为 iOS 创建 tabBarItem 图像时透明度失败

Python Subprocess.Run 不运行 Inkscape pdf 到 svg

c++ - 从 DXF 文件中解析不完整的椭圆

image - DXF图像实体组码解释

css - 是否可以使用 css 设置外部 svg 文件的样式?

css - 如何将 SVG 嵌入到单个 hta/htm 文档中?