Connecting object vertices between objects in geometry nodes with lines

Using geometry nodes, can I create curves between all vertices of two objects?

I'm hoping to produce the following result, where you can see all three vertices of each object are connected resulting in a total of 9 curves.

So far, I've only been able to connect to the nearest index of the other object, shown here:

produced by this node tree:

Thanks!

You can, if you like, do this without a repeat-zone..

• Instance a cluster of (target_vertex_count) duplicate edges on each vertex of the source mesh, stashing the duplicate_index of the edges in each cluster
• Move the endpoints of each realized edge to the stashed duplicate_index vertex position of the target mesh:

thus:

• very nice one!! +1 Jan 31 at 16:26

one way of doing this is using two nested repeat zones, so that you can iterate for each index of one mesh over each index of the other mesh like this:

result:

You can use indices to place all the wanted segments:

Get the domain sizes of the two initial meshes. Multiply them to duplicate a segment.

Get the index of the vertices from the duplicated and get half of it (this half indicate one segment).

This modulo the first object size allows to pick a position onto the first mesh.

And divided by this same size allows to pick a position onto the second mesh.

Keep one or the other depending on the parity of the index.

(File in Blender 4.0, but the node tree will work with 3.6)

PS: of course if you want curves, start with a curve line instead of mesh line and duplicate the splines instead of the segments.

• Answers 1 second apart... I think they're distinct enough.. Jan 31 at 11:13
• @RobinBetts They are and yours is more simple (1 hour apart, do you mean?) Jan 31 at 11:15
• It's weird how delivery syncs up.. I got notification when I was nearly finished... Jan 31 at 11:17

(Using Blender 3.6.5)

Following is an approach quite similar to lemon's, but keeping instances instead of "realized" objects.
It is assumed that all transformations were "applied" to the curve to instance. Furthermore, its Z axis will be aligned between connected vertices. So its size along this axis must be equal to 1. Beside, its origin is put at mid-height along this axis.

1. Let $$nS$$ and $$nT$$ be the number of vertices in Source and Target geometries, respectively. A Points node is creating a $$nS \times nT$$ points cloud, used afterwards to instance the curve.
2. Such a point index (labelled $$i$$) is split to recover the index of a Target vertex (labelled $$iT$$) and the index of a Source vertex (labelled $$iS$$). Arbitrarily, $$i$$ is defined as $$i = iT + nT \times iS$$ (NB: index values start at 0, not 1). So: $$\begin{array}{rcl} i & \equiv & iT \pmod {nT} \\ iS & = & (i - iT)\ /\ nT \end{array}$$ 3. The position of the Target (resp. Source) vertex with index $$iT$$ (resp. $$iS$$) is recovered through a Sample Index node set in Point domain. It is labelled $$\vec{T}$$ (resp. $$\vec{S}$$).
4. Transformations of the curve to instance are computed from $$\vec{S}$$ and $$\vec{T}$$.
4.1. The mid-point between S and T is used to put the curve origin. It is defined by $$\frac{1}{2}(\vec{T}+\vec{S})$$.
4.2. The curve local Z axis is aligned to the vector connecting S to T. It is defined by $$\vec{T}-\vec{S}$$.
4.3. The distance between S and T is used to scale the curve along its local Z axis. The scaling factors are defined by $$(1,1,\|\vec{T}-\vec{S}\|)$$.
5. An Instance on Points node is creating curve instances, using the position, rotation and scaling factors computed at step 4.

Resources: