Option Explicit 'Script written by Russell Loveridge 'Script copyrighted by Call Main() ' This script show how to "NEST" two loops to create a 2d field of objects Sub Main() 'declare our variables Dim strObject ' the identifyer of the current object Dim intUnits ' the number of units along one side of the square field - Note this is an integer - you cannot make 1/2 of an object.... Dim dblArea ' the user input size of the field Dim dblSize ' the standard size of each object Dim i,j ' counter variables for the loops Dim arrCorner(7)' this is the array that defines the corners of the boxes ' ask the user for the dimension of the side of the square field. dblArea = Rhino.GetReal("Input the Size of the overall field", 120) If (VarType(dblArea) = vbNull Or (dblArea <= 0)) Then Exit Sub ' ask the user how many objects /side - ' Note it is easier to ask for the number of objects than thier size, because if the division does not give an integer you need to decide how to deal with the fraction. intUnits = Rhino.Getinteger("How many units/row do you wish to have", 10) If (VarType(intUnits) = vbNull Or (intUnits <= 0)) Then Exit Sub ' find out how many units will fit in the area... dblSize = (dblArea/intUnits) ' a note to the command line to tell the user the size of each component. Rhino.print "Size = " & dblSize For i = 1 To intUnits For j = 1 To intUnits arrCorner(0) = Array(((i-1)*dblSize),((j-1)*dblSize),0) ' this is the first corner = lower left corner arrCorner(1) = Array((i*dblSize),((j-1)*dblSize),0) ' corner 2 arrCorner(2) = Array((i*dblSize),(j*dblSize),0) ' corner 3 arrCorner(3) = Array(((i-1)*dblSize),(j*dblSize),0) ' corner 4 - the last corner of the bottom level... arrCorner(4) = Array(((i-1)*dblSize),((j-1)*dblSize),dblSize) 'this is the first corner on the top of the box arrCorner(5) = Array((i*dblSize),((j-1)*dblSize),dblSize) 'top corner 2 arrCorner(6) = Array((i*dblSize),(j*dblSize),dblSize) 'top corner 3 arrCorner(7) = Array(((i-1)*dblSize),(j*dblSize),dblSize) 'last top corner strObject = Rhino.AddBox (arrCorner) Next Next End Sub