我已经为此挣扎了一段时间,似乎在任何地方都找不到一个(有效的)答案。我有一个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中的g元素(组)中删除transform属性,您可以将组移动到其最终位置,取消分组,然后重新分组所有元素。现在已经创建了一个新组,如果您不再次移动它,它将不会获得附加的transform属性。

其他回答

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.

我找到了问题所在。我希望不必求助于罗伯特的回答,尽管我很高兴确认它会起作用!Duopixel的答案实际上是最接近的,尽管事实证明还有其他原因。

When you're working with different paths in Inkscape documents, I believe its default behaviour is to group them together under an <svg:g.../> tag. When modifying paths in a group, Inkscape will automatically add a transform to the group to represent these changes. However, if you open the XML editor and drag your path outside the <svg:g.../> tag and make it its own <svg:path.../> tag, Inkscape is free to edit the individual points at will. In the end it did turn out to be a grouping problem even though I was only working with one path! Hope this helps others in similar situations.

选择有问题的元素 对象>取消分组(重复直到所有内容都取消分组;参见嵌套节点的XML编辑器) 对象到路径(将多边形转换为路径) 对象>变换>取消相对移动>应用

在这种情况下,只需将翻译添加到每个子的m值,即-10.254587 + 10.75 = -0.504587和-308.96875 + 345.43597 = 36.46722。

因为例子中所有的项都是相对的(即小写)。如果有任何是绝对的(大写),例如M或C,它们也必须进行调整。

对于缩放,你基本上是将所有子值乘以缩放。

如果有人在草图3中找到解决方案,选择该图层,然后单击图层->路径->Flatten。