i tried to create a recursive function with python that choose a random point from a nearest points group.
It works but now i want analyze the result and depending on some conditions i want to recall the function.
How can a function can be called again till the conditions is met?
import scriptcontext import rhinoscriptsyntax as rs import ghpythonlib.components as gc import random import Rhino visiblept = [startpt] cullindexin.remove(startpt) def path(closestpt,cullist): # 1 # choose a random point from nearest points and do this process recursiv # store these random points in a list called visiblept i = gc.ListItem(closestpt,random.choice(closestpt),True) visiblept.append(i) L = cullist L.remove(i) P = gc.ClosestPoints(i,L,5) if len(visiblept) <= iterator: return path(P,L) path(closestptin,cullindexin) # 2 # create a polyline from visiblept and check for self intersection Curveguid = rs.AddPolyline(visiblept) Curve = rs.coercecurve(Curveguid) events = Rhino.Geometry.Intersect.Intersection.CurveSelf(Curve,0.001) # 3 # if self intersection is True do 1 again till selfintersection is False # if len(events) > 0: # HOW CAN I CALL THE PATH FUNCTION AGAIN
Any help is welcome.