How to join multiple nearest neighbouring nodes?

Post questions on how to use or achieve an effect in Inkscape.
theozh
Posts: 437
Joined: Fri Mar 23, 2012 6:30 pm

How to join multiple nearest neighbouring nodes?

Postby theozh » Sat Apr 22, 2017 4:53 am

For example, I have many short paths (with just 2 nodes) which look like a longer dashed path.
Is there an efficient way to connect these paths to one continuous path? (not just combine with Ctrl+K)
If possible, I want to avoid a hundred times manually selecting 2 nodes pairwise and joining them or completely redrawing the line.

I know that an open path can be closed simply by the node tool with marking all nodes and join selected nodes. It will be closed with a straight line between the end nodes.
So, my hope was that I could join multiple nodes to a contiuous path in a similar way. But of course, joining endnodes is different than joining to the next neighbouring node.
The extension "Interpolate" seems right from its name but it interpolates between two shapes.
Maybe there is still a way which I do not see? Thank you for hints...

JoiningMultipleEndnodes.png
JoiningMultipleEndnodes.png (5.92 KiB) Viewed 4329 times
Win7/64, Inkscape 0.92.2

Lazur
Posts: 4717
Joined: Tue Jun 14, 2016 10:38 am

Re: How to join multiple nearest neighbouring nodes?

Postby Lazur » Sat Apr 22, 2017 5:30 am

Select all nodes, deselect the start-end nodes of the stitched path and connect nodes.
Isn't that's what you after?

theozh
Posts: 437
Joined: Fri Mar 23, 2012 6:30 pm

Re: How to join multiple nearest neighbouring nodes?

Postby theozh » Sat Apr 22, 2017 5:51 am

In this example there are 25 paths with 2 nodes each. What do you mean with start-end nodes? What do you mean with "connect" nodes? This one?
JoinSelectedNodes.png
JoinSelectedNodes.png (8.35 KiB) Viewed 4314 times

Doesn't work for me... Each of the 25 paths will get closed, but no interconnection...
If I combine (Ctrl+K) the 25 paths first and deselect the start and end node I will get a line between the second and the second last node.
Win7/64, Inkscape 0.92.2

Lazur
Posts: 4717
Joined: Tue Jun 14, 2016 10:38 am

Re: How to join multiple nearest neighbouring nodes?

Postby Lazur » Sat Apr 22, 2017 6:10 am

It joins the nearest nodes, so it's not 100% perfect all cases, but it should work to some extent:
Image


The spaces in between your dashes are larger than between two connected nodes, that's whyit doesn't work. Not sure yet how to handle that problem the best.

theozh
Posts: 437
Joined: Fri Mar 23, 2012 6:30 pm

Re: How to join multiple nearest neighbouring nodes?

Postby theozh » Sat Apr 22, 2017 6:15 am

Thanks, @Lazur, I used the measure tool an saw that the paths in my example were about 5mm long but the gaps were about 5.12mm. So, the nearest neighbour node is always on the same path not on the neighbouring path.
So, then I guess if the gaps are larger than the lenghts of small paths there won't be any chance to get them connected?
Win7/64, Inkscape 0.92.2

Lazur
Posts: 4717
Joined: Tue Jun 14, 2016 10:38 am

Re: How to join multiple nearest neighbouring nodes?

Postby Lazur » Sat Apr 22, 2017 6:18 am

The same method as in the other topic where you split apart a path to its markers may be an approximate option here.
With markers you can extrapolate the segments a bit and then they could be joined.

Approximate as in you will have many unnecessary and jittered nodes compared to the core path. But would it really matter once you add a simplify path effect atop?


Edit:
Another workaround that could work similarly is when you scale up each segment with the transformation panel before the stitching.

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: How to join multiple nearest neighbouring nodes?

Postby brynn » Mon Apr 24, 2017 6:30 am

Lazur wrote:It joins the nearest nodes, so it's not 100% perfect all cases, but it should work to some extent:

The spaces in between your dashes are larger than between two connected nodes, that's whyit doesn't work. Not sure yet how to handle that problem the best.


Interesting. It seems buggish to me. Although there maybe be some explanation. I don't find any reported bugs, although that's no guarantee there aren't any. I'd be glad to ask on the mailing list, if there's a reason for it, or if it should be reported.

When I tried it with the spaces and the short paths of equal length, it seems to randomly join different nodes. Like for example, the first time I tried, the few dashes are joined as expected, but then the next dash is connected to a dash a few steps away, and leaves those in between not connected. But undo everything, and try again, this time different dashes are connected as expected and different ones are skipped. (I tested on straight horizontal path. Maybe different if it's not straight??)

theozh wrote:If possible, I want to avoid a hundred times manually selecting 2 nodes pairwise and joining them or completely redrawing the line.

If your path is more or less horizontal or vertical, like in your example, you can drag a selection box, to select all but the outside end nodes. Or as Lazur suggested, select all, then deselect the 2 outside nodes.

theozh
Posts: 437
Joined: Fri Mar 23, 2012 6:30 pm

Re: How to join multiple nearest neighbouring nodes?

Postby theozh » Wed Apr 26, 2017 10:39 pm

theozh wrote:...the paths in my example were about 5mm long but the gaps were about 5.12mm. So, the nearest neighbour node is always on the same path not on the neighbouring path.
So, then I guess if the gaps are larger than the lenghts of small paths there won't be any chance to get them connected?

An option/feature/extension for connecting to the nearest neighbour but excluding just closing the same path would be nice. Although, probably too special for being realized...?!
Win7/64, Inkscape 0.92.2

tylerdurden
Posts: 2344
Joined: Sun Apr 14, 2013 12:04 pm
Location: Michigan, USA

Re: How to join multiple nearest neighbouring nodes?

Postby tylerdurden » Wed Apr 26, 2017 10:59 pm

Could you post an example dashed path file to experiment with?
Have a nice day.

I'm using Inkscape 0.92.2 (5c3e80d, 2017-08-06), 64 bit win8.1

The Inkscape manual has lots of helpful info! http://tavmjong.free.fr/INKSCAPE/MANUAL/html/

theozh
Posts: 437
Joined: Fri Mar 23, 2012 6:30 pm

Re: How to join multiple nearest neighbouring nodes?

Postby theozh » Wed Apr 26, 2017 11:14 pm

sure...
Attachments
JoinMultipleNodes_Test.svg
(33.92 KiB) Downloaded 149 times
Win7/64, Inkscape 0.92.2

tylerdurden
Posts: 2344
Joined: Sun Apr 14, 2013 12:04 pm
Location: Michigan, USA

Re: How to join multiple nearest neighbouring nodes?

Postby tylerdurden » Wed Apr 26, 2017 11:20 pm

Thanks!
Have a nice day.

I'm using Inkscape 0.92.2 (5c3e80d, 2017-08-06), 64 bit win8.1

The Inkscape manual has lots of helpful info! http://tavmjong.free.fr/INKSCAPE/MANUAL/html/

tylerdurden
Posts: 2344
Joined: Sun Apr 14, 2013 12:04 pm
Location: Michigan, USA

Re: How to join multiple nearest neighbouring nodes?

Postby tylerdurden » Wed Apr 26, 2017 11:41 pm

You might try the tweak tool in enlarge mode to lengthen the segments before combining and joining nodes with segments. It kinda works here... length control is a bit inconsistent due to "by-hand" application of the tweak, but as long as the segments are longer than the gaps, the join-nodes operation performs as expected.

Since the code for the enlarge exists, it might be possible to cobble an extension together that applies a parametric value to a selection.
Have a nice day.

I'm using Inkscape 0.92.2 (5c3e80d, 2017-08-06), 64 bit win8.1

The Inkscape manual has lots of helpful info! http://tavmjong.free.fr/INKSCAPE/MANUAL/html/

theozh
Posts: 437
Joined: Fri Mar 23, 2012 6:30 pm

Re: How to join multiple nearest neighbouring nodes?

Postby theozh » Thu Apr 27, 2017 12:10 am

Thanks, @tylerdurden. Up to now, I didn't know what the Tweak Tool was good for ;-).

Well, you could also use the Transform Tool (Shift+Ctrl+M) to scale each path (if you check "apply to each object separately"), e.g. by 150% and the gaps might get small enough to be connected by the "node join tool". However, you will get a pretty humpy path.
Although, the original idea was to have equidistant nodes on a path, which almost works (viewtopic.php?f=5&t=32190&p=97896) if there weren't the original path nodes which disturb the regularity.
Maybe a special extension (to be written ;-)) might be able to fit a new bezier curve through selected nodes...?
Win7/64, Inkscape 0.92.2

tylerdurden
Posts: 2344
Joined: Sun Apr 14, 2013 12:04 pm
Location: Michigan, USA

Re: How to join multiple nearest neighbouring nodes?

Postby tylerdurden » Thu Apr 27, 2017 12:23 am

My experiments with the transform panel resulted in horizontal and vertical scaling, not scaling along the axis of the paths. By contrast, the tweak tool extends the length of each path individually.

Hmmm.... maybe it amounts to the same.
Have a nice day.

I'm using Inkscape 0.92.2 (5c3e80d, 2017-08-06), 64 bit win8.1

The Inkscape manual has lots of helpful info! http://tavmjong.free.fr/INKSCAPE/MANUAL/html/


Return to “Help with using Inkscape”