Sort intersected curves

I have some random planar curves, some of them have intersections. I’d like to sort list of intersected curves. For example I’m figured out that curve 0 2 intersected, and 1 3 intersected - i wanna have list of 2 branches with 0 2 and 1 3 items. If curve 0 intersected with 2 and 3 - one branch with 0 2 3 items. (12.2 KB)

Maybe there are other simple ways (9.4 KB)


OMG, you’re right. Really clear and simple solution. But in occasion when one curve intersect another more then one time your solution didn’t work as i expect. And also your def is not detect intersected curves inside other curve.

1 Like

You didn’t ask that in the first post :wink:

1 Like

Ma bad =( Sorry if i set objective wrong. I thought that “Random curves” means many ways of collisions. i’ve already found the way how to detect that one curve intersect another (maybe multiple times). I have list of pairs of curves with intersections. My problem is how to sort this results. For example curve 1 intersect curve 0 and curve 0 intersect 2 (no matter how much times). Also there’s curve 3 and 4 with intersection. So i need to sort result to have one branch with 0 1 2 curves, and second branch with 3 4 curves inside it.

Check this topic.

And search or wait for more simple solutions, sometimes few components can solve a complex problem (14.4 KB)


Here something crazy :upside_down_face: (27.1 KB)

This is a possible solution by exploiting manifold edges of meshes, by using [Mesh join] and [Split disjoint meshes] functions.

First used MCX to have all the possible intersections.
Then used indexes to create single-faced quad meshes on XZ plane with Z edges with X coordinate equal to the indexes.
Join mesh will then join quads that share an edge , but it is not limited to a single coupling: all the quad faces that share a single edge will be merged into a single mesh.
(3 curves touching into a single point cannot be joined into a single object, but meshes can and will)
Disjointed the meshes.
Extracted the vertexes of the mesh and re-converted X values into indexes.

Better version of the same concept by @seghierkhaled here Sets question


It’s absolutely brilliant and crazy at the same time =)!
Thant you so much! And thank you all who help me to find solution!

Check this
I use script of David Rutten to combine branches where items have the same value

Grp crvs int .gh (13.4 KB)

find a way to get the same result as David script


This more simple, intersection component already do the job
@DavidRutten, Hello David can you convert your script to a component ? this solve many problems like this

1 Like