top of page
  • Writer's pictureDavid Mans

Re Orient Curves

💻 Rhino 5

🔼 Rhino Script

🛠️ Visual Basic


This Rhino Script takes allows the user to select a series of curves and a curve to reference them against. From this relationship, the user can select a new curve that will deform the series of curves relative to the difference between the two reference curves.

Option Explicit 
'Script written by <David Mans> 
'Script copyrighted by <Neoarchaic Studio> 
'Script version Sunday, May 10, 2009 11:12:11 PM 
Call Main() 
Sub Main() 
    Dim strCurve: strCurve = Rhino.GetObject("Select Origin Rail", 4, True) 
    If isNull(strCurve) Then Exit Sub
    Call Rhino.LockObject(strCurve) 
    Dim arrCurves: arrCurves = Rhino.GetObjects("Select Relative Curves", 4, False) 
    If isNull(arrCurves) Then Exit Sub
    Call Rhino.LockObjects(arrCurves) 
    Dim strRail: strRail = Rhino.GetObject("Select Target Rail", 4, False) 
    If isNull(strRail) Then Exit Sub
    Dim dblSamples: dblSamples = Rhino.GetInteger("Samples", 30, 3) 
    If isNull(dblSamples) Then Exit Sub
    Call Rhino.UnlockObject(strCurve) 
    Call Rhino.UnlockObjects(arrCurves) 
    Call Rhino.EnableRedraw(False) 
    Call orientCurves(strCurve, strRail, arrCurves, dblSamples) 
    Call Rhino.EnableRedraw(True) 
End Sub
Function orientCurves(strCurve, strRail, arrCurves, dblSamples) 
    orientCurves = Null 
    Dim i, j, k 
    Dim arrPoint 
    Dim cDom(2), dblParam(2), plan(1) 
    Dim arrCtrlPt(), arrOutput() 
    ReDim arrCtrlPt(dblSamples), arrOutput(uBound(arrCurves)) 
    cDom(0) = Rhino.CurveDomain(strCurve) 
    cDom(2) = Rhino.CurveDomain(strRail) 
    For i = 0 To uBound(arrCurves) Step 1 
        cDom(1) = Rhino.CurveDomain(arrCurves(i)) 
        For j = 0 To dblSamples Step 1 
            For k = 0 To 2 Step 1 
                dblParam(k) = cDom(k)(0) + (cDom(k)(1) - cDom(k)(0)) / dblSamples 
            arrPoint = Rhino.EvaluateCurve(arrCurves(i), dblParam(1) * j) 
            plan(0) = Rhino.CurvePerpFrame(strCurve, dblParam(0) * j) 
            plan(1) = Rhino.CurvePerpFrame(strRail, dblParam(2) * j) 
            arrCtrlPt(j) = orientPoint(arrPoint, plan(0), plan(1)) 
            Next arrOutput(i) = Rhino.AddInterpCurve(arrCtrlPt, 3) 
    orientCurves = arrOutput
End Function
Function orientPoint(arrPoint, arrOriginPlane, arrTargetPlane)
    orientPoint = Null 
    Dim arrOutput, tempPt, arrPoints(3) 
    arrPoints(0) = Rhino.PointAdd(arrOriginPlane(0), arrOriginPlane(1)) 
    arrPoints(1) = Rhino.PointAdd(arrOriginPlane(0), arrOriginPlane(2)) 
    arrPoints(2) = Rhino.PointAdd(arrTargetPlane(0), arrTargetPlane(1)) 
    arrPoints(3) = Rhino.PointAdd(arrTargetPlane(0), arrTargetPlane(2)) 
    tempPt = Rhino.AddPoint(arrPoint)
    Call Rhino.OrientObject(tempPt, array(arrOriginPlane(0), arrPoints(0), arrPoints(1)), array(arrTargetPlane(0), arrPoints(2), arrPoints(3))) 
    arrOutput = Rhino.PointCoordinates(tempPt) 
    Call Rhino.DeleteObject(tempPt) 
    orientPoint = arrOutput 
End Function

1 view

Recent Posts

See All


bottom of page