13.4.09
Easter Egg
This is just for laughs, nothing serious, ok? Had some fun doing this small Easter Script.
1. Create a sphere in Rhino and stretch its control points to turn it into an egg
2. run the script below
3. Happy Easter!
Here's the script:
Option Explicit
'
'
'
' . Easter Stripe Egg
' . script written by Alessio Erioli
' .
' . v. 12 April 2009 + 22:05:27
' . © Alessio Erioli
' . monkey Rulez, so play by the rulez.
'____________________________________________________________________________________
Call Easteregg()
Sub Easteregg()
' input surface and division intervals
Dim strSurf: strSurf=Rhino.GetObject("select a surface",8)
' vertical subdivision intervals (<=200, otherwise sweep fails)
Dim intVInt: intVInt=Rhino.GetInteger("n. of V intervals?",200,10)
'lights off!
Rhino.EnableRedraw False
' get surface domain (u and v)
Dim arrUdom,arrVdom, zminPt, zmaxPt
arrUdom = Rhino.SurfaceDomain(strSurf,0)
arrVdom = Rhino.SurfaceDomain(strSurf,1)
' get zmin and zmax points
zminPt=Rhino.EvaluateSurface(strSurf,array(arrUdom(0),arrVdom(0)))
zmaxPt=Rhino.EvaluateSurface(strSurf,array(arrUdom(0),arrVdom(1)))
Dim i, inc, angInc, ang, arrPt, arrPt2, vect, strCrv
Dim arrPts: ReDim arrPts(intVint)
' hetght and angle increments
inc = (zmaxPt(2)-zminPt(2))/intVint
angInc = 180/5
ang = 0
For i = 0 To IntVint
' point along vertical
arrPt= array (zminPt(0),zminPt(1),zminPt(2)+(i*inc))
' second point for vector construction
arrPt2 = array (zminPt(0)+1,zminPt(1),zminPt(2)+(i*inc))
' vector construction and rotation
vect= Rhino.VectorCreate(arrPt, arrPt2)
vect=Rhino.VectorRotate(vect,ang+i*angInc,array(0,0,1))
' projects point to surface
arrPts(i)=Rhino.ProjectPointToSurface(arrPt,strSurf, vect)(0)
If Isnull(arrPts(i)) Then
arrPts(i)=arrPt
End If
Next
' create base curve
strCrv = Rhino.AddInterpCurve(arrPts,3)
Dim arrPlane,arrCircles, dblrad
ReDim arrCircles(intVint)
' create circular sections along curve
For i=0 To intVint
arrPlane=Rhino.CurvePerpFrame(strCrv,Rhino.CurveClosestPoint(strCrv,arrPts(i)))
dblrad=sin(i*pi/intVint)+0.001
arrCircles(i)=Rhino.AddCircle(arrPlane,dblrad)
Next
' add a sweep 1 rail surface
Call Rhino.Addsweep1(strCrv, arrCircles)
' hide unnecessary elements
Rhino.HideObject strCrv
Rhino.HideObject strSurf
Rhino.HideObjects arrCircles
' lights on!
Rhino.EnableRedraw True
End Sub
k.words:
Easter,
fun,
RhinoScript
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment