# Geometry Nodes: Merge Points by Distance between different Mesh Islands

I've a setup of a mesh that consists of three mesh islands, where #2 is randomly positioned between #1 and #3 (figure 1 and 2).

Figure 1

Figure 2

I would like to merge the points of #2 on both sides with #1 and #3, but not with each other (not merging points within a mesh island). When increasing the distance of the merge by distance node the upper for points are merged (figure 3)

Figure 3

When distance increasing continues, the bottom points also merge, but with the points that had already been merged before. The result is that mesh island 2 changes in a plane-like structure instead of the previous cube-like structure (figure 4).

Figure 4

I understand the reason of this second merging but I can't figure out how to merge the bottom points with the points below them as in figure 5.

Figure 5

I have found that the points merge well if I manually increase the distance even further. However, when the value is increased too much, the mesh becomes a mess. I would like to procedurally do this in a model with variable distances between mesh islands 1 and 3 and a randomly positioned mesh island 2. How to make the right selection for the merge by distance node, in which points are being merged between different mesh islands but not within the same mesh island, and the "basic-shape" is retained?

For convenience I've added the blend file below.

## 1 Answer

Since we don't have a Not Connected mode for the merge by distance node, you'll need some workaround for now

In order for this method to work, you need to be able to select the part that shouldn't get merged with itself. In this case, I used a vertex group named "center_part"

Then, with the sample nearest and sample index nodes, I moved the points of the two other parts to the nearest points of the center part.

The geometry proximity is used as a threshold so it doesn't move and merge all the points

Then I joined back all the parts and merged them with a low value (since the points share the same position you don't need to increase it)

• This is what I also came up with. The only difference being that I used the Position-socket from the Geometry Proximity-node instead of a Sample Nearest-node. Mar 20 at 17:15
• Tnx for your answers! After some trying it seems to work most of the time but still gives some bugy results (see update in question).
– EwSa
Mar 20 at 21:44
• @EwSa are you able to share the file with bugy results? It shouldn't actually merge the center mesh island at all if done correctly, you might have done something wrong in the node setup imgur.com/a/As0tFXS
– Alex
Mar 20 at 23:47
• @Alex Tnx! Found it! It works correct now.
– EwSa
Mar 21 at 4:42