This script is creating several generations of groups of spheres at different height:
Option Explicit
‘If it is working then scripted by Eduardo Mayoral
‘If Not scripted by anyone else
Call Spheres()
Sub Spheres()
’===================================================
’ Set Up Starting Position
’===================================================
Dim arrPt1, intGenerations
arrPt1=Rhino.GetPoint
intGenerations = Rhino.GetInteger
Call generate(arrPt1, intGenerations, 1)
End Sub
‘===================================================
‘ Function to generate number of Spheres
‘===================================================
Function generate(arrPt, intGenerations, intCurrentGen)
If intCurrentGen < intGenerations Then
Dim intSpheres, arrGenPt
intSpheres = CInt(funcRnd(5,3))
Rhino.Print intSpheres
arrGenPt = funcGeom(intSpheres,arrPt)
Call generate(arrGenPt, intGenerations, intCurrentGen+1)
End If
End Function
‘===================================================
‘ Function to control Distances between Spheres
‘===================================================
Function funcGeom(intSpheres,arrPt)
Dim i, strLine, dblAngle, arrEndPt, Lines
Dim d1, d2
d1 = funcRD (12,9)
d2 = funcRD (40,30)
dblAngle = 360/intSpheres
For i = 0 To intSpheres
If i <> intSpheres Then
strLine = Rhino.AddLine(arrPt, array(arrPt(0),arrPt(1)+d2,arrPt(2)+2*d2))
Call Rhino.RotateObject(strLine,arrPt,(i*dblAngle))
arrEndPt = Rhino.CurveEndPoint(strLine)
Call Rhino.AddSphere(arrEndPt,funcRnd(15,3))
Else
strLine = Rhino.AddLine(arrPt, array(arrPt(0),arrPt(1)+d2,arrPt(2)+d1))
Call Rhino.RotateObject(strLine,arrPt,funcRnd(360,dblAngle))
arrEndPt = Rhino.CurveEndPoint(strLine)
funcGeom = arrEndPt
End If
Next
Lines = Rhino.ObjectsByType(4)
Call Rhino.DeleteObjects(Lines)
End Function
‘===================================================
‘ Random Function for Distances and Radius
‘===================================================
Function funcRnd(intMax,intMin)
Randomize
funcRnd = (intMax – intMin)+(rnd+intMin)
End Function
0 responses so far ↓
There are no comments yet...Kick things off by filling out the form below.