# Geometry nodes, how to select nearest edges of mesh islands

is there a way to select edges that are close to each other from different mesh islands using geometry nodes ?

(for example, select edges that are less than 1 meter close to each other.

(these are edges that i'd like to be selected)

blender 3.6.1

.....................................

what I mean by nearest edges :

I want to select edges, which centers are within e.g. 1 meter of each-other.

(blender 3.6.1)

• How would you define the distance of an edge to another edge? See this Q&A to see how tricky it is to define it rigorously: Geometry Nodes: How the nearest face/edge is found? Aug 14 at 20:47
• thanks for the deep explanation, in other words, Blender nearest is different from what we call nearest. Aug 15 at 7:51
• No, it's different from what you call "nearest". I'm fine with it in case of an edge. Aug 15 at 10:05

There are multiple problems to solve here, mainly:

• While Geometry Proximity node will nicely calculate the distance to the nearest edge by finding the closest point on that edge, it will do so only for a single coordinate (Source Position); in order to get the minimum distance between two edges, you need either to use maths to calculate it, or (what I decided to do due to laziness) sample multiple points along the edge, and take the minimum.
• A common problem with Geometry Proximity is that it returns self: because the closest element to a particular element is just itself… So you need to delete self before using Geometry Proximity, and since geometries can't be fields, without a Repeat Zone you can only achieve it with preparing multiple duplicates of the geometry, and spreading them away from each-other so they don't interact by accident, and that's exactly what I do below. Since B3.6 there's also an Index of Nearest node that ignores self, but you want to ignore more than self, you want to ignore all elements from the same mesh island, and this node doesn't support it; it allows you to group elements together, but it searches within the group rather than excluding it :(

Notice how edges sharing the corner often light up simultaneously; they don't light up exactly simultaneously when the corner isn't the closest to the other island:

## Another try

Since you refuse to define what you mean by "nearest", I can only guess. Previously I marked edges, on which there's a point, for which you can find a point on another mesh island, that is less than $$x$$ away.

Below a solution that marks edges, on which every point satisfies the condition; in other words, mark each edge, where for each point lying on this edge you can find a point on another island less than $$x$$ away.

## Third time lucky

Mark each edge, which center is less than $$x$$ away from a center of some another edge belonging to another mesh island:

Replace the Group Output with the following setup to see the selection:

• thank u for your solution, but i need something more accurate to select exactly all edges near to each other, is it possible to achieve that using math ? i have no idea how to do it. Aug 15 at 7:54
• @Pooyaheydari accuracy is not the problem here. It's the definition of "near". What do you mean by "near"? Mark two edges there and tell me why you expect them to not be selected and I'll explain why they are selected. Aug 15 at 10:04
• @Pooyaheydari Bottom branch: I'm duplicating the entire starting geometry as many times as there are islands, because for each island I want the geometry without that island. So that's the 2nd step, for each duplicate (where the 'first duplicate' with index $=0$ is the original) delete the mesh island with the same index (captured earlier, because after duplication you get more mesh islands) as the duplicate index. I also move the duplicates apart by Duplicate Offset, to make sure "proximity" always works within the correct duplicate. Aug 15 at 14:23
• @Pooyaheydari Top branch: capture island index, because I'm about to delete some geometry (I think it actually can be removed, the islands are still there, just faceless...), delete internal edges (face neighbors = 2, though I did face neighbors != 1, in this case both are the same), quick fix of the previous setups to convert edges to points, since that spawns points on centers of edges and that's what you want to check against... And then check against it, offsetting current position the same way bottom branch was offsetting, to test against the right duplicate. Aug 15 at 14:27
• thank you for helping me. I couldn't have done it without you. Aug 15 at 22:21