top of page
Writer's pictureDavid Mans

Ripple Objects about Curve

💻 Rhino 5

🔼 Rhino Script

🛠️ Visual Basic

 

This Rhino Script allows the user to select a series of objects to undulate or spiral about an axis, applying optional scalar values.

 
Option Explicit 
'Script written by <David Mans> 
'Script copyrighted by <Neoarchaic Design> 
'Script version Sunday, October 09, 2008 11:21:36 PM 
Call Main()
Sub Main() 
    Call arrayRotateAboutCurve() 
End Sub
Function arrayRotateAboutCurve() 
    arrayRotateAboutCurve = Null 
    Dim i,j, objects,angle, originPln, steps, scale, curve, pt(2), dom, crvFrame, rotFrame, rotWav, disWav 
    objects = Rhino.GetObjects("Select Objects") 
    If isNull(objects) Then Exit Function
    pt(0) = Rhino.GetPoint("Select Origin Point") 
    If isNull(pt(0)) Then Exit Function
    pt(2) = Rhino.GetPoint("Select Point for X Axis")
    If isNull(pt(2)) Then Exit Function
    pt(1) = Rhino.GetPoint("Select Point for Y Axis")
    If isNull(pt(1)) Then Exit Function
    originPln = Rhino.PlaneFitFromPoints(pt) 
    curve = Rhino.GetObject("Select Curve", 4) 
    If isNull(curve) Then Exit Function
    Dim arrItems, arrValues, arrResults 
    arrItems = array("Steps", "End Rotation", "Rotational Waves", "End Scale", "Scalar Waves") 
    arrValues = array(10, 90, 1, 0.25, 1) 
    arrResults = Rhino.PropertyListBox(arrItems, arrValues,, "Spiral Settings") 
    steps = CDbl(arrResults(0)) 
    angle = CDbl(arrResults(1)) 
    rotWav = 1 / (CDbl(arrResults(2)) * 2) 
    disWav = 1 / (CDbl(arrResults(4)) * 2) 
    If CDbl(arrResults(3)) > 1 Then
        scale = CDbl(arrResults(3)) - 1 
    Else
        scale = 1 - CDbl(arrResults(3))
    End If
    Call Rhino.EnableRedraw(False)
    Call rhino.SelectObject(curve) 
    Call rhino.Command("reparameterize 0 1")
    Call rhino.UnselectAllObjects()
    dom = Rhino.CurveDomain(curve)(1) 
    Dim tmpObj, tmpPnt, dblScale 
    For i = 0 To steps Step 1 
        crvFrame = Rhino.CurvePerpFrame(curve, (dom / steps) * i) 
        rotFrame = Rhino.RotatePlane(crvFrame, angle * Cos(i / (steps * rotWav) * pi), crvFrame(3)) 
        For j = 0 To uBound(objects) Step 1 
            If CDbl(arrResults(3)) < 1 Then
                dblScale = 1 - (scale - scale * Cos(i / (steps * disWav) * pi)) * 0.5
            ElseIf
                CDbl(arrResults(3)) > 1 Then
                dblScale = 1 + (scale - scale * Cos(i / (steps * disWav) * pi)) * 0.5 
            Else dblScale = 1 
            End If
            tmpObj = Rhino.OrientObject(objects(j), pt, array(rotFrame(0), Rhino.PointAdd(rotFrame(0), rotFrame(1)), Rhino.PointAdd(rotFrame(0), rotFrame(3))), 1) 
            Call Rhino.ScaleObject(tmpObj, rotFrame(0), array(dblScale, dblScale, dblScale)) 
        Next
    Next
    Call Rhino.EnableRedraw(True) 
End Function
 


1 view

Recent Posts

See All

Comments


bottom of page