How to calculates a point on a curve at x value by rvb?

How to calculates a point on a curve at x value by rhinoscript?

Maybe something like this?

Option Explicit
'Script by Mitch Heynick ©
'Version 4 February, 2015

Call FindIntersectPointsOnCurve()
Sub FindIntersectPointsOnCurve()
    Dim crvID, xVal
    crvID = Rhino.GetObject("Select curve", 4, True)
    If IsNull(crvID) Then Exit Sub
    xVal = Rhino.GetReal("Value along x axis to test?", 0.0)
    If IsNull(xVal) Then Exit Sub
    Dim plane, insec, i, ptStr, msg
    plane = Rhino.WorldYZPlane()
    plane(0) = Array(xVal, 0, 0)
    insec = Rhino.PlaneCurveIntersection(plane, crvID)
    If IsArray(insec) Then
        msg = ""
        For i=0 To Ubound(insec)
            If insec(i, 0) = 1 Then
                ptStr = Rhino.Pt2Str(insec(i, 1))
                msg = msg & "Intersection point found at " & ptStr & vbNewline
                msg = msg & "Part of curve parallel to Y axis at " & Cstr(xVal) & vbNewLine
            End If
        Call Rhino.MessageBox(msg)
        Call Rhino.Print("Curve does not go through X=" & Cstr(xVal))
    End If
End Sub
1 Like

Code worked.Thanks.

Of course, this is much more fun to do in Grasshopper…

1 Like