Can GH realize loop by its components, or has to refer to script (python, vb...)?

This question puzzles me for a while.
As you see, there are three groups of points (1, 2, 3). I want to find the shortest line from the points of upper group to points in lower group. Now I have created the lines from group 1 to group 2. But if I want to continue to create group 2 to 3, or if there are more groups…, I have to re-create the same lines. If there some components to realize the loop, or I have to use Python?
Thanks for any suggestion or idea! (15.3 KB) points.3dm (28.7 KB)

Grasshopper can not natively loop. You can script a loop or use a plugin like Anemone.

Thank you so much for your suggestion! I will try it soon!

This could be one way of doing it without loop. (9.4 KB)

If you use Closest Point, you can get the same result but sometimes if there are two points that have same distance, than the result would be slightly different… (13.2 KB)

Hi Kim, thank you so much for your kindness! I really need some time to understand your programming:)

Hi Kim,
I studied your programming carefully. It has a very smart strategy! And it works for any number of point groups. However, I still don’t understand why you use the “reverse” for W and “-1” for S in the for the shift list component. I tried different settings for shift list but the results were all failed. Could you please have a more detailed explanation on this?
Thank you very much!

Most of the GH components do not require much explanation as they can easily tell the difference by using them.

1 Like

That’s clear. You are right, I should use them more.
Thanks again, Kim, and have a nice week!!