Extract Centreline of polylines

Hello All,

I would like to get centreline of closed polylines, though its not centre always as it adapts to other centelines linearly. I have attached image for reference and also geometry to test it. Is there any gh component to achieve this? please help!!

centreline-query-01.gh (2.1 KB)

It is not far from medial axis. You will find some discussions on this forum

And a question does all your lines are always in 2 directions ?

Yes almost always

You don’t ask a simple question and there is not just an answer. I think you could better work with the rectangles from the other discussions and extract their center lines and work with that. But it is not simple.

The best I could do with Medial Axis

1 Like

Ya seems a tough job. thanks

There is quite better with Sand Dunes


I am there now



center_lines_frompolylines_rectangles.gh (33.1 KB)
Warning : Rhino tolerances are used so some errors could occurs if tolerances are too high or too low !!!




8 Likes

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

Hello
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:
image
image
image

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 !
image
image
center_lines_frompolylines_rectangles_v2.gh (26.4 KB)

2 Likes

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.

Basically:

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

2 Likes

Nice work!

1 Like

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