Is there any method in Python that can merge collinear lines

Is there any method in Python that can merge collinear lines

Get all lines endpoints and call TryFitLineToPoints:


231026_MergeColinearLines_00.gh (8.4 KB)

2 Likes

Thank you very much for this method. I would like to know if there are any other lines that can connect to the endpoints of multiple collinear lines

I want the second effect, and the third image uses lines

See what the attached does and try to translate it to P (good luck: hope dies last).

Clusters_CoLinearLinesl_V1.gh (184.3 KB)

Steps:

  1. Learn how to code (NOT with computer on).
  2. Get the gist of a classic hard flat Clustering (NOT possible via LINQ or a “classic” double Loop).
  3. Get the gist of finding the “extremes” of a given Colinear pts collection. That said that’s elementary: just OrderBy the collection 2 times (see inside C#).

BTW: This is the classic Clustering approach without using pre-filters (as is the norm in real-life). Clustering means: find indices.

And for this case this is the 1M question: