C# API like PointClosestObject

Hello, I want to find the closest object (textobject, curveobject and so on) from a point.
I found PointClosestObject function but it doesn’t seem to be C# API.
Is there any C# API like it?
If not, could you let me know alternative way to do that?

Thanks in advance. :smiley:

1 Like

Hi @hyunsoo1.kim,
You would probably need to use the closest point method for each type (brep, text entity plane origin, curve…), and then sort by proximity distance.

You can also try the following trick: create a very small line whose starting/ending point is your initial distance measuring point. Its length can equal Rhino document tolerance. Convert line to Curve, and use Curve.ClosestPoints method. It accepts GeometryBase list as an input, so in case of text, you would still have to use its plane origin.

Thanks for kind answer. If I use ClosestPoints function, it would return a point, then should I iterate all the objects on the document to check which object contains this closest point?

Hi @hyunsoo1.kim,
This is one option. The other is to directly use the “whichGeometry” output, to get the closest “geometry” index:
image