# Merge Lines with same direction and points in common

**URL:** <https://forum.dynamobim.com/t/merge-lines-with-same-direction-and-points-in-common/24347>\
**Category:** Geometry\
**Tags:** python\
**Created:** [July 31, 2018, 7:47pm UTC](https://forum.dynamobim.com/t/merge-lines-with-same-direction-and-points-in-common/24347 "2018-07-31T19:47:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![carolina.machado](https://avatars.discourse-cdn.com/v4/letter/c/65b543/32.png) [@carolina.machado](https://forum.dynamobim.com/u/carolina.machado)\
**Post date:** [July 31, 2018, 7:47pm UTC](https://forum.dynamobim.com/t/merge-lines-with-same-direction-and-points-in-common/24347/1 "2018-07-31T19:47:26Z")

</div>

Hello!

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](https://forum.dynamobim.com/uploads/short-url/uDzsARP5o6XW2g1w2zjvlYOvavR.txt) (2.2 KB)

Thank you in advance!

---

<div class="post-metadata">

**Author:** ![Ewan\_Opie](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/ewan_opie/32/77070_2.png) [@Ewan\_Opie](https://forum.dynamobim.com/u/Ewan_Opie)\
**Post date:** [July 31, 2018, 7:54pm UTC](https://forum.dynamobim.com/t/merge-lines-with-same-direction-and-points-in-common/24347/2 "2018-07-31T19:54:58Z")

</div>

Have you read this topic by @Vikram_Subbaiah  
[Grouping of Curves with Design Script](https://forum.dynamobim.com/t/grouping-of-curves-with-design-script/15122)

---

<div class="post-metadata">

**Author:** ![Dimitar\_Venkov](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/dimitar_venkov/32/2068_2.png) [@Dimitar\_Venkov](https://forum.dynamobim.com/u/Dimitar_Venkov)\
**Post date:** [August 1, 2018, 2:20am UTC](https://forum.dynamobim.com/t/merge-lines-with-same-direction-and-points-in-common/24347/3 "2018-08-01T02:20:51Z")

</div>

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

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/a/3a754c26f2f9eaadc8170326959c1180422cdb00.png)

---

<div class="post-metadata">

**Author:** ![carolina.machado](https://avatars.discourse-cdn.com/v4/letter/c/65b543/32.png) [@carolina.machado](https://forum.dynamobim.com/u/carolina.machado)\
**Post date:** [August 2, 2018, 10:50am UTC](https://forum.dynamobim.com/t/merge-lines-with-same-direction-and-points-in-common/24347/4 "2018-08-02T10:50:26Z")

</div>

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.
