我已经为此挣扎了一段时间,似乎在任何地方都找不到一个(有效的)答案。我有一个SVG文件,看起来像这样:

<svg

   xmlns:dc="http://purl.org/dc/elements/1.1/"
   ...
   width="72.9375"
   height="58.21875"
   ...>
   ...
   <g
     ...
     transform="translate(10.75,-308.96875)"
     style="...">
     <path
       inkscape:connector-curvature="0"
       d="m -10.254587,345.43597 c 0,-1.41732 0.17692,-2.85384 0.5312502,-3.5625 0.70866,-1.41733 2.14518,-2.82259 3.5625,-3.53125 1.41733,-0.70866 2.11392,-0.70867 3.53125,0 1.41732,0.70866 ... z"
       ... />
  </g>
</svg>

我想删除transform="…"行,但仍然有我的图像留在我已经放置它(在InkScape)。如果我手动删除转换,图像将压缩到屏幕的另一部分(正如预期的那样),但我需要完全删除转换,同时让图像保持在我想要的位置。是否有一种方法可以移除/平展转换到路径坐标本身?(我唯一需要处理的变换是平移和缩放,没有矩阵。)


当前回答

我的具体问题是在页面外定义的符号,因此需要在页面上显示转换。

为了在不需要转换的情况下将符号移动到页面上,我必须在Inkscape中执行以下步骤:

打开符号窗口(Shift+Ctrl+Y) 从文档库中删除该符号。(窗口里有个按钮。) 现在图形显示在文档中,在页面边界之外。 取消图形分组。(这是至关重要的一步!) 将图形移动到页面边界内。 将图形添加回符号库。

其他回答

This seems random, but nothing else I tried worked, so here you go random other person. Some of my paths had a sort of margin around them that could only be seen when selecting them (). I think this was created when I pasted a layer from another inkscape file and rotated it 90 deg. This made a pattern fill on the shapes have a different transform (lines spaced further apart). It also made align objects not work as expected. Using the Apply Transform mentioned by @Piotr_cz fixed the transform problem, but the strange margin remained. I accidentally got rid of it by changing the Blur on Stroke to any value and changing it back to zero.

虽然我更喜欢Inkscape,但Affinity Designer(约40美元/ Mac)在使用Android Vector Drawables时为我节省了数小时的精力。

打开一个SVG,文件->导出-> SVG ->更多->扁平化转换效果很好。

在我的例子中,组实际上是由层引起的。删除文档中的所有层删除了组和转换(可能与取消对象分组并重新分组等结合在SVG文件中删除转换(answer-35490189 from @Charlie above))

如何在Inkscape中删除变换

打开svg文件在Inkscape 进入编辑->全选 执行“Object ->取消分组” 进入编辑-> XML编辑器 在图层中找到“transform”属性并删除它们

如何在不创建另一个转换属性的情况下移动所有对象

点击编辑->在所有图层中选择全部 进入对象->变换

在变换面板

取消选中“相对移动”,分别选中“应用到每个对象” 根据需要设置“水平”和“垂直”值,单击“应用”

在Inkscape上打开svg:

选择包含所有要去掉的变换的组 按CTRL + U(取消组) 按CTRL + G(再次分组)

通过这种方式,您将摆脱应用到该组的转换,它们将被转移到包含在该组中的路径。