Option Explicit
‘Script written by <Jili Huang>
‘Script copyrighted by <USC>
‘Script version 2010年10月16日 22:36:41
Call Main()
Sub Main()
Dim cir,i,cen
cir=Rhino.GetObjects(“cir”,4)
Dim r
For i = 0 To UBound(cir)
Call Rhino.EnableRedraw(False)
r=Rhino.CircleRadius(cir(i))
Call start3(cir(i),r)
Next
Call Rhino.EnableRedraw(True)
End Sub
Function start3(ByVal cirz,ByVal r)
Dim srf
srf=Rhino.AddPlanarSrf(Array(cirz))
Dim para,cen
cen=Rhino.CurveAreaCentroid (cirz)
para=Rhino.SurfaceClosestPoint(srf(0),cen(0))
Dim vec
vec=Rhino.SurfaceNormal(srf(0),para)
vec=Rhino.VectorScale(vec,2*r)
Dim cirs,cenk
cirs=rhino.CopyObject(cirz,vec)
cenk=rhino.PointAdd(cen(0),vec)
Dim ca,vecca
ca=rhino.CurveStartPoint(cirs)
vecca=rhino.VectorCreate(cenk,ca)
vecca=rhino.VectorScale(vecca,0.8)
cirs=rhino.ScaleObject(cirs,cenk,array(0.85,0.85,0.85))
Dim rs
rs=Rhino.CircleRadius(cirs)
If rs>0.1 Then
Dim a
a=Rnd
If a>0.6 And a<=1 Then
Call branch2(cirz,cen,vec,r,a)
End If
cirz=rhino.ScaleObject(cirz,cen(0),array(1.25,1.25,1.25))
Dim incen,incir,invec,invecs
invec=rhino.VectorScale(vec,0.5)
incen=rhino.PointAdd(cen(0),invec)
incir=Rhino.copyObject(cirz,invec)
Dim cb,veccb
cb=rhino.CurveStartPoint(incir)
veccb=rhino.VectorCreate(incen,cb)
veccb=rhino.VectorScale(veccb,0.6)
incir=rhino.ScaleObject(incir,incen,array(0.6,0.6,0.6))
Dim curvesrf,loftsrf()
curvesrf=rhino.AddLoftSrf(array(cirz,incir,cirs))
Rhino.deleteobject cirz
Rhino.deleteobject incir
Rhino.deleteobject srf(0)
Call start3(cirs,rs)
Else
Rhino.deleteobject cirs
End If
End Function
Function branch2(ByVal cir,ByVal cen,vec,ByVal r,a)
Dim pt
pt=rhino.PointAdd(cen(0),vec)
Dim x,cirsmall
x=Rhino.CurveStartPoint(cir)
cirsmall=rhino.ScaleObject(cir,cen(0),array(0.8,0.8,0.8))
Dim vecaxis
vecaxis=Rhino.VectorCreate(cen(0),x)
Dim vecb
vecb=Rhino.VectorRotate(vec,45,vecaxis)
vecb=Rhino.VectorUnitize(vecb)
vecb=Rhino.VectorScale(vecb,r)
Dim i
For i=1 To 6 Step 1
vecb=Rhino.VectorRotate(vecb,60,vec)
Dim vecx
vecx=Rhino.vectorscale(vecb,1.6)
Dim cen2
cen2=Rhino.pointadd(cen(0),vecx)
Dim vecxx,cirb
vecxx=rhino.VectorCreate(cen2,cen(0))
cirb=rhino.CopyObject(cir,vecxx)
Dim srfsc,ptd
srfsc=rhino.AddSrfPt(array(pt,cen(0),cen2))
ptd=rhino.SurfaceClosestPoint(srfsc,cen2)
Dim vecfc
vecfc=rhino.SurfaceNormal(srfsc,ptd)
cirb=rhino.RotateObject(cirb,cen2,-45,vecfc)
cirb=rhino.ScaleObject(cirb,cen2,array(0.4,0.4,0.4))
Rhino.deleteobject srfsc
Dim r2
r2=Rhino.CircleRadius(cirb)
If r2>0.1 Then
Dim srfas
srfas=rhino.AddLoftSrf(array(cirb,cirsmall))
Call start3(cirb,r2)
Else
Rhino.deleteobject cirb
End If
Next
End Function