My SVG has multiple line objects forming a closed shape. I must convert this into a single path, so that a laser cutting machine just follows the path to cut the shape from the material without jump.
Of course this can be manually done with inkscape by:
- Converting all individual objects into one path, resulting in a single path but two overlapping nodes at each angle of the shape
- For each angle, select both nodes that share the same coordinates and Join selected nodes (Shift+J)
However it requires to perform step 2) thousands of times (once per angle), is there an option to merge all overlapping nodes automatically?
Even if in my case, coordinates of overlapping nodes perfectly match, since there is no perfect equality between floats, eventually a distance could be provided to research overlapping nodes, e.g. all nodes n1, n2
for which distance(n1, n2) ≤ 1e-6 mm
(or in pixels) are merged into a single node.
Conflicts start to happen if there are more than 2 nodes within this tolerence, however the Join selected nodes (Shift+J) tool itself seems not to handle this case and only merge two nodes.
This option might also be useful to duplicate a single shape several times on a board, and prevent the laser from cutting a same edge several times damaging the material. But it seems more advanced because there are several paths.
Here is an example of input file:
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
version="1.1" id="svg5169"
viewBox="0 0 20.302442 20.250575"
height="5.7151623mm"
width="5.7298002mm">
<g
transform="translate(-41.214011,-1123.8181)"
id="layer1">
<g
transform="matrix(0.99667782,0,0,0.99980745,-163.30415,1035.5366)"
id="g4" />
<path
id="line134"
d="m 41.339286,1123.9953 20,0"
style="stroke:#191919;stroke-width:0.35433069;stroke-miterlimit:4;stroke-dasharray:none" />
<path
id="line138"
d="m 41.339286,1123.9434 20,20"
style="stroke:#191919;stroke-width:0.35433072;stroke-miterlimit:4;stroke-dasharray:none" />
<path
id="line142"
d="m 61.339287,1143.8181 0,-20"
style="stroke:#191919;stroke-width:0.35433072;stroke-miterlimit:4;stroke-dasharray:none" />
</g>
</svg>
And the output I need to produce to send to the laser-cutting machine, i.e. the same object with a single path:
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
version="1.1" id="svg5169"
viewBox="0 0 20.604885 20.60488"
height="5.815155mm"
width="5.8151565mm">
<g
transform="translate(-84.099911,-1123.8181)"
id="layer1">
<g
transform="matrix(0.99667782,0,0,0.99980745,-163.30415,1035.5366)"
id="g4" />
<path
id="line142-9"
d="m 104.52763,1123.9953 -20.000004,0 20.000004,20 z"
style="fill:none;stroke:#191919;stroke-width:0.35433072;stroke-miterlimit:4;stroke-dasharray:none" />
</g>
</svg>