Mobile app version of vmapp.org
Login or Join
Lengel450

: Automatically merge overlapping nodes in inkscape 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

@Lengel450

Posted in: #Inkscape #LaserCutting #Path #Svg

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>

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Lengel450

1 Comments

Sorted by latest first Latest Oldest Best

 

@Karen819

Referring to the provided source, you need to:


ungroup (Shift-Ctrl-G) your object, select the paths and combine (Ctrl-K) them in a single path
switch in Edit paths by nodes mode (F2), select all the nodes and join selected nodes (Shift-J).




When all the nodes are selected, the join selected nodes function applies to all the couples of endnodes found.

If the coordinates of your nodes overlaps perfectly, this should work (you don't need to repeat your step 2. thousands of times).

In case the coordinates of the nodes doesn't overlap, Inkscape joins the nodes but you can obtain unexpected behaviors, e.g.:



So, the use of the join on all the nodes should be used with a bit of carefulness.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme