Merge Lines with same direction and points in common


I am pretty new in Dynamo and in Python so I’m facing some troubles and I need your help.
I have a list with Lines. Some of this Lines can be tranformed in one bigger line. I don’t know how to do this. I’ve tried some Custom Nodes and I’ve tried to write a Python Script (below). None of these worked.

Does anyone know any Custom Node that does this? Or if not, can you tell me what’s wrong in my code?

The inputs to the script I wrote is:

  • listaDir = List with Points representing the direction of the lines.
  • listaPI = List with the start points of the lines.
  • listaPF = List with the end points of the lines.

The script is in the txt file uploaded.

Script - Merge Lines.txt (2.2 KB)

Thank you in advance!

Have you read this topic by @Vikram_Subbaiah
Grouping of Curves with Design Script


Maybe the CurveLoop.Simplify from Springs will do what you need?


Thank you all for the replies!
I tried your solutions and the solutions inside @Ewan_Opie’s solution and I find one to me and also discovered that my project for testing was inappropriate.

The solution use the Group Curves node from the archilab package, then I transform them into Polycurves with PolyCurve.ByJoinedCurves and then I got the Start and End Points.