1209extrude

Option Explicit
‘Script written by Macus Chen
‘Script copyrighted by <insert company name>
‘Script version Wednesday, December 09, 2009 9:10:30 PM

Call Main()
Sub Main()

Dim objSrf
objSrf = rhino.GetObjects(“get surfaces to shrink and extrude”,8)

Dim cPt, i, arrParam, arrNormal, extrudeSrf,line,extrudePt
‘scale
rhino.EnableRedraw False

For i = 0 To Ubound(objSrf)
cPt = centerPt(objSrf(i))
objSrf(i) = rhino.ScaleObject(objSrf(i),cPt,array(0.75+rnd*0.2,0.75+rnd*0.2,0.75+rnd*0.2))

arrParam = Rhino.SurfaceClosestPoint(objSrf(i), cPt)
arrNormal = Rhino.SurfaceNormal(objSrf(i), arrParam)

arrNormal = Rhino.VectorUnitize(arrNormal)
arrNormal = rhino.VectorScale(arrNormal,0.02+0.03*rnd)

extrudePt = rhino.PointAdd(cPt,arrNormal)

line = rhino.AddLine(cPt,extrudePt)

extrudeSrf = rhino.ExtrudeSurface(objSrf(i),line)

Next

‘extrude
rhino.EnableRedraw True

End Sub

Function centerPt(obj)

Dim bbox
bbox = Rhino.BoundingBox(obj)
centerPt = Array( (bbox(0)(0) + bbox(6)(0))/2, (bbox(0)(1) + bbox(6)(1))/2, (bbox(0)(2) + bbox(6)(2))/2 )

End Function

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s