top of page
  • Writer's pictureDavid Mans

Surface Wave

💻 Rhino 5

🔼 Rhino Script

🛠️ Visual Basic

 

Surface wave is a very simple rhinoscript tool that uses a curve to create a sine wave-based surface. Developed as a means to expedite surface experimentation, its function as a tool is very limited, but its results as an origin are quite useful.

 
Option Explicit
'Script written by <David Mans>
'Script copyrighted by <Neoarchaic Design>
'Script version Sunday, May 25, 2008 11:21:36 PM
Private aA,aB,aC,aD,aE,aF
Call Main()
Sub Main()
    Dim curves
    curves = Rhino.GetObjects("Select Curve", 4)
    If isNull(curves) Then Exit Sub
     
    If IsEmpty(aF) Then
        aF = 2
    End If
    If IsEmpty(aA) Then
        aA = 20 
    End If
    If IsEmpty(aB) Then
        aB = 2 
    End If
    If IsEmpty(aC) Then
        aC = 3
    End If
    If IsEmpty(aD) Then
        aD = 90
    End If
    If IsEmpty(aE) Then
        aE = 90
    End If
     
    Dim b, arrItems, arrValues
    arrItems = array("waves", "steps", "baseLength", "increaseLength", "baseRotation", "increaseRotation")
    arrValues = array(aF, aA, aB, aC, aD, aE)
    b = Rhino.PropertyListBox(arrItems, arrValues,, "Volume Parameters")
     
    aA = CDbl(b(1)): aB = CDbl(b(2)): aC = CDbl(b(3)): aD = CDbl(b(4)): aE = CDbl(b(5)): aF = CStr(b(0))
    Call Rhino.EnableRedraw(False)
    Dim i
    For i = 0 To ubound(curves) Step 1
        Call reparameterize(curves(i))
        Call quickStems(curves(i), aA - 1, aB, aC, aD, aE * .5, aF)
    Next
    Call Rhino.EnableRedraw(True)
     
End Sub
Function quickStems(curve, steps, bLen, length, bRot, rotation, waves)
    quickStems = Null
    Dim i
    Dim crvDom, ori, pln, plnR, len, rot, vect, wav
    Dim finCrv
    ReDim crv(steps),pt(steps)
    crvDom = Rhino.CurveDomain(curve)
    wav = 1 / waves
    For i = 0 To steps Step 1
        len = length - length * Cos(i / (steps * wav) * pi)
        rot = rotation - rotation * Cos(i / (steps * wav) * pi)
        ori = Rhino.EvaluateCurve(curve, crvDom(1) / steps * i)
        pln = Rhino.CurvePerpFrame(curve, crvDom(1) / steps * i)
         
        plnR = Rhino.RotatePlane(pln, rot - brot, pln(3))
        vect = Rhino.PointAdd(ori, Rhino.VectorScale(Rhino.VectorUnitize(plnR(2)), bLen + len))
         
        pt(i) = vect
    Next
    finCrv = Rhino.AddInterpCurve(pt)
    Call Rhino.AddLoftSrf(array(finCrv, curve))
End Function
Function reparameterize(strObjectID)
    If Rhino.IsCurve(strObjectID) = True Then
        Call rhino.SelectObject(strObjectID)
        Call rhino.Command("reparameterize 0 1")
        Call rhino.UnselectAllObjects()
    End If
    If Rhino.IsSurface(strObjectID) = True Then
        Call rhino.SelectObject(strObjectID)
        Call rhino.Command("reparameterize 0 1 0 1")
        Call rhino.UnselectAllObjects()
    End If     
End Function
 


0 views

Recent Posts

See All
bottom of page