Option Explicit 'Script written by Morten Bülow 'Script copyrighted by archpoint.dk 'Script version 06-10-2009 'General: '$phideg = 90: vertical up! '$thetadeg = 0; east! '$thetadeg = 90; south! '$thetadeg = 180; west! '$thetadeg = 270; north! 'sunposition copenhagen: 'Altitude max: 57 deg. 'Altitude min: 10 deg (the building is placed in the city, so the building isn't affected by the direct sun before it's 10 deg over the horizon) 'Create a surface and rebuild it! 'Turn on the Surface Control Points and run the script! Call Main() Sub Main() Dim dblRadius, intCount, rndNr, i Dim thetaDeg, phiDeg, phi, theta Dim arrPointLoc, arrGripLocs, srf srf = Rhino.GetObject("Select Surface",8) dblRadius = Rhino.GetReal("Distance increment") intCount = Rhino.GetInteger("iterations",1000) arrGripLocs = Rhino.ObjectGripLocations(srf) ' Call Rhino.EnableObjectGrips (srf, True) Call Rhino.EnableRedraw (False) For i = 0 To intcount Step 1 thetaDeg = RandomNumber(54,305) phiDeg = RandomNumber(10,52) theta = Rhino.ToRadians(thetaDeg) phi = Rhino.ToRadians(phiDeg) rndNr = RandomNumber(0,(Ubound(arrGripLocs)-1)) arrPointLoc = arrGripLocs(rndNr) arrPointLoc(0) = arrPointLoc(0) + dblRadius*Rhino.SinH(phi)*Rhino.CosH(theta) arrPointLoc(1) = arrPointLoc(1) + dblRadius*Rhino.SinH(phi)*Rhino.SinH(theta) arrPointLoc(2) = arrPointLoc(2) + dblRadius *Rhino.CosH(phi) Call Rhino.ObjectGripLocation( srf, rndNr, arrPointLoc) Next Call Rhino.EnableRedraw (True) End Sub Function RandomNumber(nLow,nHigh) Randomize RandomNumber = CInt((nHigh - nLow + 1) * Rnd + nLow) End Function