select objects/paths 的 Inkscape CLI 语法

Inkscape CLI syntax to select objects/paths

我有以下 SVG 文件:

<svg width="18px" height="18px" viewBox="0 0 18 18" version="1.1" xmlns="http://www.w3.org/2000/svg">
<title>Kalender</title>
<g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
    <g transform="translate(-178.000000, -704.000000)" stroke="#0067C5">
        <g transform="translate(139.000000, 20.000000)">
            <g transform="translate(36.000000, 681.000000)">
                <polyline points="7 5.66666667 4.33333333 5.66666667 4.33333333 19.6666667 19.6666667 19.6666667 19.6666667 5.66666667 17 5.66666667"></polyline>
                <polygon points="7 4.33333333 9 4.33333333 9 7 7 7"></polygon>
                <polygon points="15 4.33333333 17 4.33333333 17 7 15 7"></polygon>
                <path d="M9,5 L15,5"></path>
                <path d="M4.33333333,9 L19.6666667,9"></path>
            </g>
        </g>
    </g>
</g>

它由一系列带有笔划的对象组成,我需要将其转换为路径。

在 Inkscape 的 GUI 版本中,解决我的问题的步骤如下:

但我需要相同操作的 CLI 语法,以便为一系列 SVG 文件自动执行此过程。

我试过以下方法:

inkscape -f "-stroketopath/"$svgfile --verb="EditSelectAll" --verb="EditSelectSameStrokeStyle" --verb="StrokeToPath" --verb="FileSave" --verb="FileQuit"

这是行不通的。我怀疑它失败的原因与上述相同("Edit > Select Same > Stroke style" 操作不适用于常规 selection 工具(在 "Edit > Select all" 操作中使用)。

那么有人知道如何用 "Edit paths by nodes" 工具替换 --verb="EditSelectAll" 然后 select 文件中的一个或所有对象吗?

解决这个问题的方法是 运行 通过我所有的 SVG 并在 pathrect、[= 类型的第一个元素上注入一个 id="inkscape" 属性14=]、ellipselinepolylinepolygon.

那我可以运行:

inkscape -f $svgfile --select="inkscape" --verb="EditSelectSameStrokeStyle" --verb="StrokeToPath" --verb="SelectionUnion" --verb="FileSave" --verb="FileQuit"

使用 --select 命令 (details here)。

The --select command will cause objects that have the ID specified to be selected. This allows various verbs to act upon them. To remove all the selections use --verb=EditDeselect. The object IDs available are dependent on the document specified to load.