Grasshopper

algorithmic modeling for Rhino

Hello people!

I have a rhino curve, lying on the XY plane.

My VB script has 2 inputs: myCurve (as a Curve), myX (as a Double).

In my VB script, I'd like to get the "y" value, corresponding the "x" value ,  where "y" is on the vertical axis.

Have you any advice?

thanks

Views: 353

Replies to This Discussion

the ghx I can give you. The script I do not know :-)
Attachments:

Thanks a lot, Dedackelzucht.

But I had to develope a VB script.

 

any other advice? please

Here's a Rhinoscript that might suggest the method.  I don't know the VB.Net or Rhino SDK well enough to help directly.

 

Chris

 

Option Explicit

Call Main()
Sub Main()
    Dim strObject,dblX,arrStartPoint,arrEndPoint,strLine
    Dim arrObjects,strIntersectLine,arrEndPt,arrIntersectLine,dblY
    'Select the curve to evaluate.
    strObject=Rhino.GetObject("Select the curve.",4)
    If IsNull(strObject) Then Exit Sub
    'Enter the X value.
    dblX=Rhino.GetReal("Enter the X to evaluate.")
    If IsNull(dblX) Then Exit Sub
    'Define a line in the Y direction from the given X value.
    arrStartPoint=Array(dblX,0,0)
    arrEndPoint=Array(dblX,1,0)
   
    'Hide the display of operations.
    Call Rhino.EnableRedraw(False)
    'Draw a line in the positive Y direction.
    strLine=Rhino.AddLine(arrStartPoint,arrEndPoint)
    'Test to see if the line intersets the curve.  If so print the Y value.
    Dim arrTest,arrPoint
    arrTest=Rhino.CurveCurveIntersection(strObject,strLine)
    If Not IsNull(arrTest) Then
        arrPoint=arrTest(0,1)
        Call Rhino.Print(arrPoint(1))
        'If no intersection then extend the line to intersect the curve and print the Y value.   
    Else
        arrObjects=Array(strObject)
        strIntersectLine=Rhino.ExtendCurve(strLine,0,1, arrObjects)
        arrEndPt=Rhino.CurveEndPoint(strIntersectLine)
        dblY=arrEndPt(1)
        Call Rhino.Print (dblY)   
    End If
    'Delete the line drawn.
    Call Rhino.DeleteObject(strLine)
    'Enable the display.
    Call Rhino.EnableRedraw(True)
   
End Sub

Attachments:

Thank you Chris

I'll try your solution as soon as possible.

By

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service