Option Explicit '------------------------------------------------------------------------------------------- 'adding cubic modules randomly, they will be placed always so they fit with each other... 'Pablo Miranda Carranza, code released under GNU General Public License (www.gnu.org/licenses/gpl.txt) '------------------------------------------------------------------------------------------- sub random_place Dim moveto Dim i Dim thebox randomize moveto=Array(0,0,0) 'this is just to tell Rhino that 'moveto' will be an array For i=0 to 50 thebox=makecube() 'this here makes the whole trick... 'the int means that everything between parenthesis should be done in to an integer number (without fractions). 'we multiply it by 2 afterwards, which is the size (lenght, width and height of the box we will draw) moveto(0)=int(rnd()*10)*2 moveto(1)=int(rnd()*10)*2 moveto(2)=int(rnd()*10)*2 Rhino.MoveObject thebox, Array(0,0,0), moveto Next End Sub Function makecube() Dim arrVertCube(7) 'the vertices of the cube Dim Objcube1ID 'initialise the array with all the vertices of the cube...this is the way of describing a cube in Rhino 'this cube will be 2 units width, 2 units high and 2 units long, and be centred around the origin (0,0,0) arrVertCube(0)= Array(0.0,0.0,0.0) arrVertCube(1)= Array(2.0,0.0,0.0) arrVertCube(2)= Array(2.0,2.0,0.0) arrVertCube(3)= Array(0.0,2.0,0.0) arrVertCube(4)= Array(0.0,0.0,2.0) arrVertCube(5)= Array(2.0,0.0,2.0) arrVertCube(6)= Array(2.0,2.0,2.0) arrVertCube(7)= Array(0.0,2.0,2.0) Objcube1ID = Rhino.AddBox (arrVertCube) 'it needs to go between parenthesis when returning a value makecube=Objcube1ID End Function random_place