Grasshopper

algorithmic modeling for Rhino

having a bit of trouble in VB finding the right way to find a point on a curve based on a length instead of a number between 0 and 1. i guess i'm looking for the vb equivalent of the evaluate by length component instead of by paramter.

thankyou

Views: 453

Replies to This Discussion

Hi William,

There is no function for this, unless you're willing to use the RhinoDivideCurve() function which gives you potentially many points and thus might take a long time.

What you have to do is figure out the parameter along the curve at that length, and then use that parameter in conjunction with Curve.PointAt(t)

You can find this parameter with the OnCurve.GetNormalizedArcLengthPoint() function. The word "arc" in that name has nothing to do with circular arcs, so it's a confusing name. Also note that the function doesn't work with physical lengths, but with relative lengths. So if you want the parameter exactly one quarter along the total length of the curve, your s argument is 0.25.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
Here's some code that evaluates the length of the input curve, and then calculates the "T" value based on the length you input. It's really simple...I've also added an "IF" statement that requires the length to evaluate be less than the curve length.

All it does is calculate the "T" by dividing your desired distance by the total length of the curve.

Private Sub RunScript(ByVal Input_Curve As OnCurve, ByVal Distance_On_Curve As Double, ByRef A As Object)


Dim dblLength As Double
Input_Curve.GetLength(dblLength)

If Distance_On_Curve <= dblLength Then

Dim dblTParameter As Double
dblTParameter = Distance_On_Curve / dblLength

Dim pntCurve As New On3dPoint(Input_Curve.PointAt(dblTParameter))

A = pntCurve

End If

End Sub

Does the line :

 

Dim pntCurve As New On3dPoint(Input_Curve.PointAt(dblTParameter))

 

I am still getting a null point as a result 

On3dPoint is a type in the old SDK, are you using the new SDK or the old one?

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

solved it .. im using the new one so i used point3d

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