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?

Best regards

Views: 968

Replies to This Discussion

There's probably a better way to do this, and maybe someone else will come along and correct me. However, you could create a vertical plane at X,0 and then test for curve-plane intersection.

 

Rhino.Geometry.Intersect.Intersection.CurvePlane

 

I don't know how it looks exactly in VB so you might have to play around a bit. 

 

Cheers,

Chris

This should work:

 

Private Sub RunScript(ByVal C As Curve, ByVal x As Double, ByRef y As Object)

Dim cbb As BoundingBox = C.GetBoundingBox(True)

Dim pt0 As Point3d = cbb.PointAt(0, 0, 0)

Dim pt1 As Point3d = cbb.PointAt(1, 0, 0)

If x < pt0.X OrElse x > pt1.X Then

print("x is off the Curve")

Return

End If

Dim xplane As New Plane(New Point3d(x, 0, 0), Vector3d.XAxis)

Dim xe As Intersect.CurveIntersections = Intersect.Intersection.CurvePlane(C, xplane, 0.01)

y = xe.Item(0).PointA.Y

End Sub

 

This is obviously assuming that your curve isn't self-intersecting, and that for each x, there is only 1 y-value on the curve.

 

Hope it helps.

Thank you, Suryansh

Your assumption are correct.

I'try as soon as possible.

By

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service