Grasshopper

algorithmic modeling for Rhino

hi,


this may be an easy question to answer but I couldn´t find how to solve it:


I am trying to get the closest parameter of a curve from a given point but in the SDK I didn´t find a method for Curve.ClosesParameterTo (only for lines, arcs, polylines and planes) and, when using the function ClosestPoint, I don´t manage to get the point (only the boolean). A silly example:


double param = 2.0;
A = curves[0].ClosestPoint(curves[0].PointAtStart, out param);


A = True;



any clues?


cheers

Views: 837

Replies to This Discussion

Hi Miguel,

confusingly, on Curve, ClosestPoint will compute the parameter, not the point itself. Your code should work the way you typed it:

double t;
if (!curves[0].ClosestPoint(curves[0].PointAtStart, out t)) { return; }
Point3d cp = curves[0].PointAt(t);


whatever number you pass into the second parameter of the ClosestPoint method will be set to the parameter along the curve closest to testPoint.

--
David Rutten
david@mcneel.com
Seattle, WA
Hi David,

just one more thing: I didn´t understand why "whatever number you pass into the second parameter of the ClosestPoint method will be set to the parameter along the curve closest to testPoint." Is it because it gets the value from out?

Thanks
Exactly, a lot of functions in our SDK do not return values, they return booleans indicating success or failure. The actual computed values (there can be more than one) are passed in as out parameters (ByRef in VB).

--
David Rutten
david@mcneel.com
Seattle, WA
Ok, thanks!

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service