Combine items with the same location in list


Its probably a very easy question. (but I didn’t find out yet).
How do you isolate/combine items in lists, with the same location (not only the same branch).

So for instance, I would like to make multiple poly lines (between 3 points). There are 3 lists with points.
I would like to combine the same list items with each other.


Combine items with same location in (10.1 KB)

thank you :slight_smile:


Thank for your answer, unfortunately this would be to easy :slight_smile:.
The thing is that not all polylines have the same number of points. so lets say 3pt and 5pt. Because of this, the last 2 lists (point 4 and 5) will have less coordinates. By grafting the lists GH doesnot know where to stop the line…
It is really essential that all the lists data with the exact same position (branch ánd item) is extracted.
If you have any ideas please let me know.

Thanks again! :slight_smile:

sorry, should have mentioned the merge. I don’t see the 3+ pts polylines you mention.

in your image above its A,B,C,D,F all the way down.

You have duplicate points, it is ok? and your description doesn’t fit your file.

merging will respect branches, but not always order.

Ahh thanks again!

I think you are right.

Probably there is going something wrong before in the script, see attached.

I start with the coordinates of point 1, after which I add the distance (x,y,z) to come to point 2, + distance x,y,z point 3 etc…
challenge is:
when the number of points are the same it is going correct.
When the number of points is not the same it is going wrong. It is probably going wrong in the area which is highlighted in red. Because there is only 1 value present, this value is also added to the poyline which is already stopped…

Do you have any suggestions how I could omit this?

Thanks again! :slight_smile: multiple polylines 5pt and 3 (23.5 KB)

Explain what you want to do globally, it seems too messy to me.

1 Like

more trees, less spaghetti

1 Like

Oke thanks again, yes lets try to solve this in a nice way with lists.

The challenge:
I would like to draw 2 (or more) polylines based on 1 list.

In this example I would like to draw 2 polylines. Therefore the list consists of 2 branches.

A branch consists of multiple items.
Each item represents a point. whereby the values of the items represent the (Delta) x,y,z, distance to the previous point.

polyline 1 start at 0;0;0 (x;y;z), this means that the coordinate of the following points would be:
point 1: 0,0,0
point 2 2,0,0 ((0+2), (0+0) , (0+0))
point 3 2,2,0 ((2+0), (0+2) , (0+0))
point 4 -1,2,0 ((2-3), (2+0),(0+0))
point 4 -6,0,0 (-1-5), (2-2),(0+0)

polyline 2 starts at 10,0,0;
point 1: 10,0,0
point 2: 13,0,0
point 3: 0,5,0

Probably I am thinking way to complicated, but I cant see an easy/straight forward solution. If you have any suggestions please let me know…

Thanks again! :slight_smile:

Polyline 1:

Polyline 2:

When I try to make them the polyline with the least number of points is not correct drawn, it somehows interferece with the data of polyline 1: Not correct :

Thanks again for your helpmultiple polylines 5pt and 3 pt (2.1 KB)

multiple polylines 5pt and 3 pt v2 (20.9 KB)

Is this intentional?

Hi, thanks.

Ahh sorry I inisialized the data a bit to early. the data which I show is present after the cull command;

thanks :slight_smile: )

for future reference you can manually edit the data via the context menu:


Ahh oke thanks, good to know! See attached the correct file.

If you have any suggestions please let me know :slight_smile:

thanks again!

multiple polylines 5pt and 3 pt v2 (20.9 KB)

I just also saw a wrong input at the base point (point 1).
So please use the latest GH file I uploaded, which is correct :slight_smile:

Thanks again!

Your question in the first post

Thank you :slight_smile:

Know the new challenge is: what should I do if 1 list has less items …

Thanks again! :slight_smile:

I think I see the solution!
It involves some tree manipulation but the first trick is to have the first point in the polyline to be moved 0,0,0 this allows you to use the Partial list from the Mass Addition component to get the relative additions to each point.

multiple polylines 5pt and 3 (9.0 KB)

You will see null items and you need to use Clean tree
did you try it?

Ahh wauw!
I am really impressed! It does the trick and I learned a couple of very usefull commands!.

Just because I would like to fully understand the script, what does the i%count command do, could you explain it to me?

Thanks you so much, thanks! :+1: :+1: