Drawing every possible lines among several points

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

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? …

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

4 Likes

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

Haha, glad I helped :slight_smile:

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.

Hi :slight_smile:

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.

1 Like

Awesome! Thanks a lot!