How to create Meshline according to each geometric edge vertices using GeometricNodes?

I'm using Blender 3.5 , trying to create an instance of MeshLine for each geometric edge and to set each Meshline instance end points according to the corresponding edge's end points.

I succeeded to create one MeshLine for a specific edge. But I can't figure out how to make it automatically for all instances, because I don't know how can I set each MeshLine instance end points..

Here is an example for creating a Meshline according to specific geometric edge

Here is how I began to make it automatically for all geometric edges, but I have the problem shown.

• Do you need to have several vertices per mesh line or only two, as the initial edges are? Commented Apr 26, 2023 at 5:27

shmuel's answer is the good one because this is the explaination we needed, but if you want a line made by two vertices for each edge, you can simply duplicate the edges (shifted up so that we can see them in the image below).

From that if you want to have each segment composed of 10 vertices, for instance, you can convert the mesh to a curve, resample in order to have 10 vertices per curve and convert back to mesh.

Below, in edit mode, the result on top, and the initial mesh below it.

• Thank you @lemon, it is a valuable knowledge. But yes, I need MeshLine for adding vertices. Commented Apr 27, 2023 at 6:03
• @audi02, I' completed the answer. After that all depends on what you want to do with it... Commented Apr 27, 2023 at 6:16
• Thank you very much - I see now the mesh->curve for resampling and adding vertices! Commented Apr 27, 2023 at 15:20

Preface

...so you're going to have to change the way you think about GN until they add loop nodes. The way we construct most thinkinsg in GN, is using fields (and not so much static values), and the way we go about it is backwards or reverse of the way you are doing it.

Solution Explanation

In your case you want to instance the mesh line and then set the position.
You want to hold the edge position data on the edges even after they are converted into points and instanced on, that way when we make the instances real we can still use the edge data, even though we aren't working with the edges anymore.

solution

The way you do this is by

• capturing the edge vertices positions on the edges (using the capture attribute node. set the capture domain to edge).
• Then you convert it to points (mesh to points node set to edge) ,
• instance the line (on the points, using instance on points node),
• and convert the instances to real geometry (so you can actually manipulation it properly) (using the realize instances node).
• Then use the endpoint selection node together with a switch node (set to vector) to set one end of the curve to the fist vertex position and one to the second vertex position (these positions are the ones you captured).
• This vector is going the be the position (position input) of a set position node.

Alternatively you could use the mesh to points node's position input to set the position of the points to one vertex;
that way you only need to capture one attribute (that of the second vertex position),
as well you wouldn't need to use a switch node, rather you could just use the set position node's selection (with the endpoint selection node).

Here are the nodes: @lemon 's solution is better for your use case, but this is a good lesson on how GN work.

• Hello. "until they add loop nodes" do you have information about that? Is it planed? Commented Apr 26, 2023 at 5:40
• @lemon I don't really know much, but it's definitely officially planned, and we really have simulation nodes branch that has a frame based loop. try checking on blender chat. it's most probably in development or on the list. Commented Apr 26, 2023 at 7:04
• @shmul - thank you very much. I don't understand step 5 in your solution. You wrote "to set one end of the curve", but after step 4 I have a realized geometry node - not curve, nor input sockets for setting end points of the instances. I'm missing something and I guess I have to learn some more here according to your answer. I will do and respond. Or you may add a graph image. Commented Apr 27, 2023 at 6:02
• @shmuel - Yes I see now the graph which allow to learn the lesson. I guess that as lemon suggested, I can resample the curve for having more vertices along it. Commented Apr 27, 2023 at 15:22