# Drawing every possible lines among several points

**URL:** <https://forum.dynamobim.com/t/drawing-every-possible-lines-among-several-points/26687>\
**Category:** Lists-Logic\
**Tags:** dynamo\
**Created:** [October 1, 2018, 3:20pm UTC](https://forum.dynamobim.com/t/drawing-every-possible-lines-among-several-points/26687 "2018-10-01T15:20:06Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![imanebadi](https://avatars.discourse-cdn.com/v4/letter/i/53a042/32.png) [@imanebadi](https://forum.dynamobim.com/u/imanebadi)\
**Post date:** [October 1, 2018, 3:20pm UTC](https://forum.dynamobim.com/t/drawing-every-possible-lines-among-several-points/26687/1 "2018-10-01T15:20:06Z")

</div>

Hi everyone!

I’m trying to draw every possible lines among a list of points. My initial attempt was to use “Line.ByStartPointEndPoint” node and setting the lacing to “Cross Product”. However, this method gives me several duplicate lines which I do not want; i.e. lines “AB” & “BA” are different in definition but identical in appearance.

I found a way to somehow delete these duplicate lines afterward, but my goal is to not produce them in the first place because I am dealing with large number of points in order to reduce the time of processing.

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

On my second attempt, I’ve used “List.Deconstruct” and manually created my intention. My knowledge on Dynamo and coding is so limited and I could not find a way to make the process automatic! LoopWhile? …

---

<div class="post-metadata">

**Author:** ![mellouze](https://avatars.discourse-cdn.com/v4/letter/m/e47774/32.png) [@mellouze](https://forum.dynamobim.com/u/mellouze)\
**Post date:** [October 1, 2018, 3:23pm UTC](https://forum.dynamobim.com/t/drawing-every-possible-lines-among-several-points/26687/2 "2018-10-01T15:23:27Z")

</div>

There is a very simple way to do it in Python. I’ll post it here when a get it done.

Edit: Here it is. Just feed it the lists of points you need.

```
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

points = IN[0]

result = []

for i in range(len(points)-1):
	for j in range(i+1,len(points)):
		result.append(Line.ByStartPointEndPoint(points[i],points[j]));
OUT = result

```

![2018-10-01%2017_28_18-Dynamo](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/2/3/236cdb33fa7d37789c427c640d97fb187a850199.png)

---

<div class="post-metadata">

**Author:** ![imanebadi](https://avatars.discourse-cdn.com/v4/letter/i/53a042/32.png) [@imanebadi](https://forum.dynamobim.com/u/imanebadi)\
**Post date:** [October 1, 2018, 3:38pm UTC](https://forum.dynamobim.com/t/drawing-every-possible-lines-among-several-points/26687/3 "2018-10-01T15:38:20Z")

</div>

I cannot find a word to thank you enough! You made my day!

---

<div class="post-metadata">

**Author:** ![mellouze](https://avatars.discourse-cdn.com/v4/letter/m/e47774/32.png) [@mellouze](https://forum.dynamobim.com/u/mellouze)\
**Post date:** [October 1, 2018, 3:40pm UTC](https://forum.dynamobim.com/t/drawing-every-possible-lines-among-several-points/26687/4 "2018-10-01T15:40:38Z")

</div>

Haha, glad I helped 🙂

---

<div class="post-metadata">

**Author:** ![imanebadi](https://avatars.discourse-cdn.com/v4/letter/i/53a042/32.png) [@imanebadi](https://forum.dynamobim.com/u/imanebadi)\
**Post date:** [October 8, 2018, 1:15pm UTC](https://forum.dynamobim.com/t/drawing-every-possible-lines-among-several-points/26687/5 "2018-10-08T13:15:16Z")

</div>

Hi again!

As you noticed my knowledge level on Python coding… What if the input is a list containing several sublists? And I want them to be processed separately and output with the same sublist’s indices.

---

<div class="post-metadata">

**Author:** ![mellouze](https://avatars.discourse-cdn.com/v4/letter/m/e47774/32.png) [@mellouze](https://forum.dynamobim.com/u/mellouze)\
**Post date:** [October 8, 2018, 1:20pm UTC](https://forum.dynamobim.com/t/drawing-every-possible-lines-among-several-points/26687/6 "2018-10-08T13:20:56Z")

</div>

Hi 🙂

Encapsulate the Python node inside a Custom node.

When entering the Custom node, change the input (that would be something like `list : var[]..[]`) by `Point[]`. That should do the trick.

---

<div class="post-metadata">

**Author:** ![imanebadi](https://avatars.discourse-cdn.com/v4/letter/i/53a042/32.png) [@imanebadi](https://forum.dynamobim.com/u/imanebadi)\
**Post date:** [October 8, 2018, 1:56pm UTC](https://forum.dynamobim.com/t/drawing-every-possible-lines-among-several-points/26687/7 "2018-10-08T13:56:33Z")

</div>

Awesome! Thanks a lot!
