# Sort curves by vertices

I have 3d geometry with flat sections (red) which vertices are connected by lines (green). I want to label each vertex and show them on planar flat view with curves like on picutres. I have tried by unrolling surfaces but it doesnt seems to work.
I want to turn this:

into this (with all vertices labelled):
sorting_vertices.3dm (191.1 KB) sorting_vertices.gh (240.0 KB)

Hello sailor!
Something like this perhaps?

Best regards,
Sir Ernest Shackleton

boxStripper.gh (24.7 KB)

Hello,
Thanks for answer but no. Red sections and green connector lines must be separately like on picture Iâ€™ve uploaded before.

Iâ€™ve handled sorting points and labeling but have no idea how to make them flat with labels.

Iâ€™ve made it for red curves. I guess it is not most handy solution. Any ideas how to make it for green ones?

sorting_vertices.3dm (181.3 KB) sorting_vertices3.gh (843.5 KB)

This is a classic Graph (or Mesh) connectivity puzzle â€¦ meaning that youâ€™ll need VV and EV conn trees plus some basic bool ops with indices Lists (in order to locate the vertices loop(s) [conditional closed cirquits as we call them in graphs] that you want [and anything else] etc etc). If you are 100% familiar with these AND with coding matters notify for a C# solution. That said (case Mesh) MeshTopologyVertexList Class has a handy Method that sorts the neighbor vertices/edges (by the topo vertex index). Keep in mind that Vertices and Topology Vertices are NOT the same thing and have NOT the same indexing in a mesh.

1 Like

Thanks for answer. Well Iâ€™m not that advanced in gh and C# yet I wonder if there is a simpler way like measuring distance between vertices and simply draw them flat with corresponding dotsâ€¦ â€¦or unroll surfaces with green lines and remove these which duplicate red onesâ€¦but how?

Well â€¦ I have always the general case in mind when dealing with stuff like this: meaning a big and complex [say 1++ K nodes etc etc] Graph/Mesh with islands. So first comes island detection (via the VV conn Tree) and then the rest.

If you have other â€śchallengingâ€ť cases in mind as well â€¦ donâ€™t even think to deal with them without connectivity (and code).

Detecting sections and connectors isnâ€™t big issue. They are on separated layers.
Below is best solution so far but there is one more issue remained.
So Iâ€™ve got two lists. One with red lines and second with green ones. How to remove line on one list if it occurs on second list? How to remove same lenght line or same dots line? For eg this line.

sorting_vertices.3dm (187.9 KB)
sorting_vertices5.gh (1.6 MB)
Is there a lists master on forum?

Well â€¦ letâ€™s assume that reds and greens lay in different planes (i.e. are not coinsident) : the general case is to sample, say, directions (i.e. Vectors) related with the red lines and then test them against the directions related with the green ones.

Tip: Since you said that you are in the code learning path â€¦ this is a good entry level C# task for you: use the vect1.IsParallelTo(vect2, atol) Method (that yields 1 or -1 [case parallel/antiparallel]) and skip each green that yields a value 1/-1.

For that youâ€™ll need obviously a double loop (foreach green â€¦ foreach red).