Hi, you can see in my script that I defined the closest point from one starting point to all other points that are in the grid.
Now I want to use the Closest Point again and search for the closest point … and again the result…
How to define this searching in a for loop? I am tried it for hours
Thanks a lot for your help!
EDIT:
Maybe this one is better:
poolunused = sum_attractors[:]
closestattractor = []
dist = 9999999
for n in poolunused:
ee = rs.Distance(start_point, n)
if ee <= dist:
dist = rs.Distance(start_point, n)
closestattractor = n
in the end of your loop you should redefine your start point to be the found closest point, and then you should also remove the closest point from the point grid array.
Which is what the C# script does, using Point3dList is a good way to find closest point by Closest Index without spending heavy calculations on distance searches.
I also noticed the adventage of this code. Regarding to scripting efficiency I would say that python also has adventages that C# does not have. But I think this belongs to the never ending prefered language discussion. Thank you again for your time, hopefully @Dancergraham can help me now?
something like this might work, (first draft, might not be right). One advantage that C# has over Python, is the incrementer i++, that can be put right in the initialization of the loop. Python, (I don’t think…), has an equivalent ability, so you have to do it “manually”.
while len(pts) > 0:
counter = 0
for pt in pts:
if counter == 0: StartPt = StartPt
else: StartPt = a[len(a)-1]
ClosestPt = Rhino.Collections.Point3dList.ClosestIndexInList(pts, StartPt)
a.append(pts[ClosestPt])
pts.pop(ClosestPt)
counter +=1
print StartPt
This almost works for me. Awesome! But there is still the problem that my start_point0 is not the start of the string. It is just one of them inside . See attatched picture