Extract Centreline of polylines

This is very interesting almost linear except at meeting points. Thanks for the definitiion

Hi, if you could convert your geometry to rectangles, applying the solutions from your previous discussion, then it is easy.

Divide surface based on corners.

It is easy to extract the center line of a rectangle.

Tried Laurent definition works good though its not linear even if I seperate to boxes

Separating to boxes would enable you to use another approach that would give you everything linear.

Am not getting it clear what you say. I tried with closed plines rectangle still not linear enough

For sure

But after that it is not so easy !!!

1 Like

What settings should be used for bigger objects like stairs stringers? I’m trying to find a “centerline” which could help for automatic placing cups on a cnc router:
center_lines_frompolylines_rectangles (1).gh (27.4 KB)
I’d like to have a curve like your “C” shape example.

1 Like

I am not sure I understand your question, what is sure is that my script doesn’t accept more than one curve at once ! I didn’t try to implement the logic for multiples curves. It is doable but takes time.
If it is not that can you draw what you are after ?

Thank you Laurent, Ok for the single object, it works better indeed, (however in my case, grafted list of polylines would be useful :slight_smile:) Here is examples what I am looking for:

Here an updated script, it works with multiple curves, I added some slider for curve simplifications, … Hope the naming are quite explicit. But It isn’t a 100% all what you want script !
center_lines_frompolylines_rectangles_v2.gh (26.4 KB)


Thank you Laurent, you’re a killer, it’s really close to my needs. I’ll try to include this in my homemade postprocessor for my router. It transforms rough dxf geometries into Biesse .cix format, which can include the vacuum cups positions. I will have to array circles or rectangles along those center curves, and find their coordinates, not too difficult.
In french:
j’apprécie beaucoup ton travail qui souvent répond de très près à mes problèmatiques géométriques, merci encore!

1 Like

What I meant is that if you use boxes, then there is no need to use Laurent’s approach as it deals with closed curves of all types, and you only need boxes, which simplifies the task a lot.

Boxes Axes_v01.gh (19.8 KB)

Here is a simple approach. The logic is to first generate longest center line of each rectangle. And then extend those to meet up the other curves, by projecting the end point to the closest curve. Naturally this creates some diagonal lines, which are culled. Then some exterior lines, which are also culled, and finally some pieces of the axes need to be trimmed, so they are also culled depending on their distance to the edge region.


I tested for a couple of possible arrangements, and it seems to work. For now only rectangles, no squares.


Nice work!

1 Like

This is incredible work!! your neurons are on fire bows down

I tested for other polylines and it says insufficient curves. Kindly have a look.

boxes-query.gh (17.9 KB)

Hi, the reason is that the curves you inputted as rectangles are not so tidy. I created new rectangles from your curves by generating the bounding box of each one.

Boxes Axes_v02.gh (20.3 KB)

Interesting. Thanks!!

Amazing work ! I am wondering how it is possible to find the centreline between two interpcrves like the example here 11

It could be more simple here for “closed centerline”. You can use a classical Medial Axis. It will be better work for “smooth” curves.

For polylines, my script could be transformed to work for roof with patio (holes) .


If you want it really fast, turn that surface to a mesh and use z axis mesh rays instead of Brep closest point. :wink: