import rhinoscriptsyntax as rs import random as ran #delete everything and start from scratch allobj = rs.AllObjects() rs.DeleteObjects(allobj) bsize = 10 #side length of box dist = 1 #distance between boxes offs = bsize + dist #offset of boxes num = 10 #number of boxes in one row #create a box corners = [(0,0,0), (bsize,0,0), (bsize,bsize,0), (0,bsize,0), (0,0,bsize), (bsize,0,bsize), (bsize,bsize,bsize), (0,bsize,bsize)] rs.EnableRedraw(False) for i in range (num) : for j in range (num) : for k in range (num) : box = rs.AddBox(corners) rs.MoveObject(box, (i*offs,j*offs,p*offs)) rs.EnableRedraw(True) """ rs.EnableRedraw(False) for i in range (num) : for j in range (num) : for p in range (num) : # myran = ran.randint(0,9) #nur bei ungeraden zahlen if (i+j+p) % 2: box = rs.AddBox(corners) rs.MoveObject(box, (i*offs,j*offs,p*offs)) # rs.ObjectColor(box,(i*(255/num),j*(255/num),p*(255/num))) rs.EnableRedraw(True) #for i in range (num) : # for j in range (num) : # for p in range (num) : # myran = ran.randint(0,9) # if (myran >= 0 ): # if ((i+j+p)%3) and ((i+j-p)%3) and ((i-j-p)%3): # box = rs.AddBox(corners) # rs.MoveObject(box, (i*offs,j*offs,p*offs)) # else: # box = rs.AddBox(corners) # rs.MoveObject(box, (i*offs,j*offs,p*offs)) # rs.ObjectColor(box, (255,0,0) #solution hirschberg #if 0: # for i in range(num): # for j in range(num): # for p in range(num): # if ((not((i%(num-1)) and (j%(num-1)))) and # (not((j%(num-1)) and (p%(num-1)))) and # (not((i%(num-1)) and (p%(num-1))))): # box = rs.AddBox(corners) # rs.MoveObject(box, (i*offs,j*offs,p*offs))