Find closed curves from group of connected lines

Hi!

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.ExampleCurves.gh (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.

2 Likes

Hi, this seems to be what Iâ€™m looking for !
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:

240303_LinesToMeshNGonBoundaries_00.gh (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.

3 Likes

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).

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.

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).

2 Likes

Quick update, though you already solved it @emilien:

240304_LinesToMeshNGonBoundaries_00.gh (16.1 KB)

1 Like

Perfect ! Thank you so much !

1 Like