I have a list of point PT, Newlist of Point Clovknot[(i,j)] is select some of them by distance to test point.
in the Clovknot[(i,j)]. I run the loop to create lines. but when I add line 55. the computer crash. Does anyone know how to solve the problem.
question.pdf (143.9 KB)
import rhinoscriptsyntax as rs
def Main():
Pt = {}
Distance =
squknot = {}
SQCurve =
ISuqKnot =
JSuqKnot =
Clovknot = {}
IClovknot =
JClovknot =
DistClovknot = {}
TestPt = rs.GetObject(“select test point”, rs.filter.point)
for i in range(15):
for j in range(15):
x = i*2
y = j*3
z=0
Pt[(i,j)] = (x,y,z)
for i in range (15):
for j in range(15):
if i-1>0:
Distance = rs.Distance( Pt[(i,j)], Pt[(i-1),j] )
if Distance >1:
Clovknot[(i,j)] = Pt[(i,j)]
IClovknot.append(i)
JClovknot.append(j)
DistClovknot[(i,j)] = rs.Distance(Clovknot[(i,j)], TestPt)
IMAXClovknot = max(IClovknot)
IMIMClovknot = min(IClovknot)
JMAXClovknot = max(JClovknot)
JMIMClovknot = min(JClovknot)
#get the index of the smallest value
DistClovknotLIST = zip(DistClovknot.values(),DistClovknot.keys())
DistClovknotLIST.sort()
#the I and J value of the distance,
ClosestPtIJ = DistClovknotLIST[0][1]
CLOVECurve = CLOVKNOT(Clovknot,ClosestPtIJ,IClovknot,JClovknot,IMAXClovknot,IMIMClovknot,JMAXClovknot,JMIMClovknot)
def CLOVKNOT(POINT,CLOSTPT,ICLOVknot,JCLOVknot,IMAX,IMIM,JMAX,JMIM):
# get the I,J value of the startpoint
i = CLOSTPT[0]
j = CLOSTPT[1]
Curve =
if i >= IMIM and j >= JMIM and i <= IMAX and j<= JMAX:
if i-1 in ICLOVknot and j-1 in JCLOVknot:
NewPtIJ2 = (i-1,j-1)
Curve.append(rs.AddLine( POINT[(i,j)],POINT[(i-1,j-1)] ))
CLOVKNOT(POINT,NewPtIJ2,ICLOVknot,JCLOVknot,IMAX,IMIM,JMAX,JMIM) # **crash happen when add this line**
if i+1 in ICLOVknot and j+1 in JCLOVknot:
NewPtIJ = (i+1,j+1)
Curve.append(rs.AddLine( POINT[(i,j)],POINT[(i+1,j+1)] ))
CLOVKNOT(POINT,NewPtIJ,ICLOVknot,JCLOVknot,IMAX,IMIM,JMAX,JMIM)
Main()