Finding the Point on a Curve Which is the Closest Point to Another Curve? (AutoCAD .net API)

Documentation of the GetClosestPointTo method of the curve object - the overloads are extremely limited. So we have to be somewhat creative in obtaining a solution.
Documentation of the GetClosestPointTo method of the curve object – the overloads are extremely limited. So we have to be somewhat creative in obtaining a solution.

The Genesis of this problem

This is a tricky little problem and I could not find a solution on the forums. So I resolved, upon discovering the solution, to oblige posterity and the public, to publish my findings.

Specific Notes about this problem

Now the following code has been generalised to the specific case of Lines and a non-descript curve (which of course is an abstract base class), but the general principles can be applied to any type of curve.

Notes on implementation

Unfortunately, the curve object exposes a method: GetClosestPointTo, which is only overloaded to accept points and not other curves. In order to deal with this rigmarole we’ll have to first, convert the curve to a `Curve3d` object which is a member of the Autodesk.AutoCAD.Geometry namespace as distinct from the Autodesk.AutoCAD.DatabaseServices namespace.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *