#2D POINT MATRIX VERSION 03 #import modules import rhinoscriptsyntax as rs import random as rnd def PointMatrix(IMAX,JMAX,KMAX): #set up empty lists ptMtx = {} lines = [] midPts = [] #loop to generate point values as a product of the loop counter #save values in list for i in range(IMAX): for j in range(JMAX): #make x,y,z in terms of i,j,k x = i * 5+(rnd.random()*3) y = j * 5+(rnd.random()*3) z = KMAX #save point values in list (dictionary) ptMtx[(i,j)] = [x,y,z] #loop through point list and generate lines - save in list for i in range(IMAX): for j in range(JMAX): if i > 0 and j > 0: midPts.append(MidPt(ptMtx[(i-1,j-1)], ptMtx[(i,j)])) lines.append(rs.AddCurve((ptMtx[(i-1,j-1)], ptMtx[(i-1,j)], ptMtx[(i,j)], ptMtx[(i,j-1)], ptMtx[(i-1,j-1)]),1)) for i in range(len(lines)): rs.RotateObject(lines[i], midPts[i], i*.2) def MidPt(PT01, PT02): MidPt = None MidPt = [(PT01[0] + PT02[0]) / 2, (PT01[1] + PT02[1]) / 2, (PT01[2] + PT02[2]) / 2,] return MidPt #call function def main(): #get values from user imax = rs.GetInteger('maximum number x', 10) jmax = rs.GetInteger('maximum number y', 10) kmax = 0 PointMatrix(imax,jmax,kmax) main()