Find closed curves from group of connected lines


I want to be able to select the lines from a big group (which is based on the edges of some voronois + other scripts) which compose a closed polyline. So what you would see in the image would become 2 polylines. It should be able then to select twice the shared edge.

One note: the resulting polylines are NOT going to be planar.

If I should somehow rephrase it, I would like to achieve something like the reverse of a Deconstruct Brep ultimately, I have tried with the Delauney Mesh component, but I think it’s better to stick with finding closed polylines.

Also: it should not form perimter of all the possible curves, but the smallest ones that are not comprised within another curve.

Do you have an example file with non planar line segments?

Here, it’s internalised in this file. (2.3 KB)

This sort of reverse engineering (doable via code, mind the so called primary closed cirquits problem … but why waste effort that way?) is NOT the rational procedure to address similar problems. Go to the root of the matter: how these polylines are made and then:

  1. Either solve a classic Polyline in contact connectivity - like:

  1. Or solve a classic Brep in contact connectivity - like:

Bad news: is unlikely that you can do either without code (or some plug-in … if it exists). Notify if you want some hints in case that you want to attempt that kind of stuff via C#.

That said connectivity is a way to corelate one or two Lists of objects: a DataTree of type int where the path second dim (case: paths with 2 dims) or the path dim (case: path with 1 dim) is the index of the parent object in the first List and the items are the indices of objects in the second (or first) List. For instance for a Mesh a VV (V for Vertex) connectivity corelates items in one List while a VE (E for Edge) connectivity corelates items in 2 Lists.


Hi, this seems to be what I’m looking for ! :exploding_head:
Will it work on my file ?

curves to closed polylines.3dm (55.4 KB)

One can implement the native RhinoCommon lines-to-mesh method and extract the resulting NGon face loops: (15.4 KB)

I’m not sure if this is exposed in native Grasshopper components, but I think the lines-to-mesh method was originally part of the Weaverbird plugin if I recall.


Yes but it requires coding skills (mid to advanced) while all my C#'s for that are strictly internal. That said - seeing your example captured - I would strongly suggest to avoid reverse engineering.

See some general PCD cases (Primary Cirquit Detection)

If on the other hand you know how to code (C#) I could provide some hints and a general methodology for this problem. BTW the final - Recursive - phase is more or less similar with what we do for Island detection in Graphs).

Hi @AndersDeleuran

This seems perfect, I’ve just added a Close Curve to get a closed polyline !

Many Thanks.

1 Like

Ah yes, I forgot to append the first vertex to the list before making the polylines, doh! Anywho, glad it helped.

Hi @PeterFotiadis

Ok, I’m not a programmer and didn’t get what you mean by “avoiding reverse engineering” ?

Btw, I know what you are capable of, the code you shared on other topics helped me a lot on other projects. Thanks.

In your snap there’s hexagons that are made via some sort of procedure, say, by dividing a BrepFace (or you can do a flat solution and morph map it to some target). This means - at least for this case - that the hexagons should been detected at creation time. If on the other hand you have a Graph (from uknown source) that looks like a collection of hexagons and you want these hexagons (or some other thing) … well … that’s what we call reverse engineering (i.e. going from the result/end to the start).

Ok I see, it’s because I use Solidworks as my main 3D software and I use grasshopper to automate some tasks.

Well … I have tons of C#'s that divide something (Curves/BrepFaces/Breps/Meshes/Cats/Dogs etc). If you want an Entry Level C# notify (but it would be pure code meaning that you can’t modify/change a thing).

See some simple tests (with “patterns” so to speak) using BrepFaces (i.e. a Surface [open or closed in u/v - or in both dirs] with Trim data).

That said if there’s some sim/singularity (closure in u/v) the C# modifies accordingly the user u/v division values in order to achieve the obvious. The typical output is DTrees with ordered vertices (so you can do a Polyline).


Quick update, though you already solved it @emilien: (16.1 KB)

1 Like

Perfect ! Thank you so much !

1 Like