boolean tube

1

Option Explicit
‘Script written by <insert name>
‘Script copyrighted by <insert company name>
‘Script version 2009年10月5日 17:11:20

Call Main()

Sub Main()
Dim arrcontext, i, arrbln
arrcontext=rhino.getobjects(“context”,4)
For i= 0 To ubound(arrcontext)
arrbln= squeeze(arrcontext(i),10,3)

Next
End Sub

Function squeeze(spine, dividenumber,radius)
Dim divpts,i,j, circle(),srf,  circle1(), sph()

divpts=rhino.dividecurve(spine,dividenumber)
For i =0 To ubound(divpts)

ReDim Preserve plane(i)
ReDim Preserve circle(i)
ReDim Preserve circle1(i)
ReDim Preserve sph(i)

plane(i)=rhino.MovePlane(worldXYplane,divpts(i))
circle(i)=rhino.addcircle(plane(i),radius+rnd*radius)

circle1(i)=rhino.rotateobject(circle(i),divpts(i),45*i,,True)
sph(i)=thumb(circle1(i),1.2)

Next
srf=rhino.AddLoftSrf(circle)

Dim bln
‘For j=0 To ubound(sph)-1
bln=Rhino.BooleanDifference(array(srf), sph(0))
‘srf=bln
‘j=j+1
‘Next

End Function

Function thumb(circle, factor)
Dim center, i, radius, sphere()
radius=rhino.CircleRadius(circle)
radius=0.68*radius
center=rhino.DivideCurve(circle,4)

For i =0 To ubound(center)

ReDim Preserve sphere(i)
sphere(i)=rhino.addsphere(center(i),radius)
sphere(i)=rhino.ScaleObject(sphere(i),center(i),array(1,1,factor))

Next
thumb=sphere

End Function

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s