Divide long curve segments by distance

I was wondering, how do I divide polyline segments that are longer than distance X? What I want is to specify distance X and add points along the segments at distance X.

Divide Long segments.gh (10.9 KB)

I need this to operate on a file with about 30.000 curves of which 3500 segments need to be subdivided. But, with the script I have now, I can add the points that I need, but I don’t really know how I can maintain the order of the points list if I use the existing points and subdivision points to create a new polyline.

Hi @Intuos

I just come up with a solution for this case. I hope it works for you.

Divide Long segments.gh (9.7 KB)


1 Like

It’s almost there, though it fails to recognise open curves that use the same point multiple times throughout (it ignores the end point in these).

The light grey line is from the input lines, whereas the dark grey is what the GH script puts out.

This script creates the subdivided segments and non-subdivided segments separately, outputting single lines for each. I am still puzzling how I could improve it to recreate the original curves with the subdivided polylines.
Divide Long segments_Joined.gh (48.8 KB)

E: Note that I cannot just join the segments as this will ruin the Graph for the Graph analysis.

E2: I am almost there, updated the script. The issue is that I run into double small segments when joining. The short curves don’t seem to be dispatched properly. Don’t have time to work on this today, so I’ll leave it here as is.

Hi @Intuos,

Is this what you want?

Starting from your curves:

You get:

You don’t need to segregate the long and short curves - using the DivLength component anything under the threshold will just remain undivided, so all curves can be processed the same, making life simple (apart from getting the tree depths right):

Divide Long segments_Joined_ex_J.gh (47.3 KB)


1 Like