By Wayne Brill
Issue
I need to get the closest point on a plane of a component in assembly. I use FaceProxy.GetClosestPointTo(). The return value is always (0,0,0). Is there a solution for this?
Solution
Note: This issue applies to Inventor 2009.
A workaround is to use MeasureTools.GetMinimumDistance.
Note: There is a difference between the documented behavior of GetClosestPointTo and GetMinimumDistance. When using GetClosestPointTo() the face is bounded and the closest point must be on the face. When using GetMinimumDistance() the face is boundless – it can be extent and the point may not be on the measured face. Here is a VB.NET example:
Sub GetClosestPoint() Dim oFace As FaceProxy = _ _invApp.ActiveDocument.SelectSet(1) Dim oTG As TransientGeometry = _ _invApp.TransientGeometry Dim oP As Point = oTG.CreatePoint(0, 0, 0) Dim vContext As Object = Nothing Dim dDistance As Double dDistance = _invApp.MeasureTools. _ GetMinimumDistance(oFace, oP, , , vContext) Debug.Print("By Minimum Distance:") If Not vContext.Item("IntersectionFound") Then Debug.Print(vContext.Item _ ("ClosestPointOne").X) Debug.Print(vContext.Item _ ("ClosestPointOne").Y) Debug.Print(vContext.Item _ ("ClosestPointOne").Z) End If End Sub

Leave a Reply