Iterated edge drawer animation nodes

I have a set of lines instanced along a curve using "Replicate Matrix" and "Object Matrix Output."

My goal is to loop through the instanced lines and, for each one, get a random point on it, find the nearest point on the next instanced line, and make edge between them. The end result I want is edges drawn through all of the instanced lines, looking something like this:

I've tried to do the following way. First, a loop that runs through the lines and finds edge starts and ends:

The "random point" comes from the Random Number that inputs to the Get List Element, which has the vertices from the first line. I then pass these edge starts and ends out of the loop to draw the edges.

This works to some extent, but I'm having problems achieving the result I want. The result I actually get is more like this:

Edges are drawn between adjacent lines, but only between the two lines currently being compared in the loop. And the number of edges being drawn between adjacent lines increases as the loop runs. I don't understand why that is. And the edges don't accumulate as the loop runs - so the edges drawn on first iteration aren't preserved in the second, etc.

To try to fix the second, accumulation issue, I tried to make this second loop, which would save all the edges the loop calculates:

But this hasn't worked. The list in the Append gets longer after each iteration, but each element in the list gets written over with a single vector value. You can see that happening, e.g., in the Viewers connected to the Append to List nodes. It's weird.

So, that's where I am. I can't figure out how to turn something like the second drawing into something more like the first. Maybe I'm going about this whole thing the wrong way! But even just figuring out how to get the Append node to hold values across iterations would be awesome.

Here's the .blend file:

• What do you mean by "get a random vertex", a vertex from where? Can you make a simple illustration to illustrate what your inputs are and what the output is expected to be? Mar 24, 2018 at 16:34
• Thanks so much for responding! I made some big edits to the question, which I hope make things clearer, both what I'm after and how I'm trying to get it. Please let me know if I should provide more info. Mar 24, 2018 at 18:02
• I think uploading your blend file could help... Imagine people trying to understand your nodes just reading them without knowing exactly which part is connected to which from an image to another... you can upload your file here blend-exchange.giantcowfilms.com Mar 24, 2018 at 18:15
• Thank you! I uploaded the file -- I didn't know how to do that. Mar 24, 2018 at 18:52
• Are your "lines" just line segments? I mean, are they parallel to each other and flat as you illustrated or are they just line-like meshes? Mar 24, 2018 at 18:53

A spiral or a helix is described using the set of parametric equations as follows:

\begin{aligned} x &= R\cos{t}\\ y &= R\sin{t}\\ z &= \delta t \end{aligned}

Where $R$ is the radius, and $\delta$ is the vertical frequency of the curve. By implementing this, we get:

Now, we are going to move the points of the helix with a random amount in the direction of your choice, I can see you are offsetting them in the direction of the $x$ axis (This is the equivalent of sampling a random vertex along your instanced paths), so lets do that:

The points we just computed act as the first vertex of each edge, the other vertex can be computed mathematically or just by using the Project Point On Line node, the line starts are defined as the position of the next point and the ends are defined as the position of the next point plus some value in $x$ just to define the direction. To the location of the points of the next points, we simply shift the vector list backward, by doing so, each point is aligned with the one following it. Then we create the edges from the points and their projection. The node tree is as follows:

And the result is as expected (The horizontal lines are just for visual aid, not part of the implementation and they are the lines you originally had in your file):

You may notice that there is an extra edge going from the last vertex to the x axis, this is due to the fact that after shifting, the first vector became aligned with the last, and this is just a normal consequent of doing so. To fix that, just remove the last vector and last edge from the output using the slice or remove list element node.

• Wow -- thank you! I've got this working, but I'm still studying it. Conceptually, the work of the Shift node is hardest thing to get my head around, but I have some sense of it. One big problem I'm having is the Project Point node. Yours seems to accept a Vector List, while mine only accepts Vectors. So I have to step through the spiral vector list to generate the edges, and so I have the problem of getting edges only between adjacent points. Am I missing something there? Is the Project Point node that accepts vector lists only in the newer version? I have another question... Mar 24, 2018 at 20:26
• Which is: if I wanted to find the second vertex of each on another line or shape, rather than just in any old direction as defined by the Vector Math node, I would put the vertices of other other line or shape into the Line End in the Project Point node, right? Mar 24, 2018 at 20:28
• @Chris Yes, the Project Point On Line was vectorized in the new version I am using. So you have to create a loop for that node (A loop that only contains the node). I am not sure what you mean by the second question. Can you elaborate on that? Mar 25, 2018 at 13:56
• OK great -- this gets to the heart of my question. So I got the edges drawn. When I plug the various vectors into a loop as iterators, then I get all the edges at once. When I plug them into the loop as parameters, I can iterate through the loop and draw each edge individually. And the edges "accumulate" in the way I'm looking for: a new edge each iteration, between adjacent vertices, and edges drawn on previous iterations are still there. But this leads to the second question... Mar 25, 2018 at 15:20
• My original goal was not necessarily to draw an edge at every vertex in a spiral, but to draw edges between, e.g., adjacent lines instanced on the vertices of that spiral. That's why I was using the Object Matrix Output node, Object Mesh Data node, etc. But when I try to use the current solution in this way, I get my original problematic result. I can't get edges between adjacent instanced shapes to "accumulate" in the same way. I have the sense I need another loop for that, but I don't know how to do it. (Is this too much discussion for comments?? Should I ask another question?) Mar 25, 2018 at 15:21