The Edge and Face objects expose a "GetClosestPointTo" method, however transient entities do not expose a method in order to determine the closest point.
Do you have a solution for that purpose?
Solution
The "MeasureTools.GetMinimumDistance" Method can be used in order to achieve that.
Here is an example:
Public Sub TestMinimumDistance(ByVal app As Inventor.Application)
Dim entity1 As Object
entity1 = app.TransientGeometry.CreateCone( _
app.TransientGeometry.CreatePoint(0, 0, 0), _
app.TransientGeometry.CreateUnitVector(1, 0, 0), _
5, 0.2, True)
Dim entity2 As Object
entity2 = app.TransientGeometry.CreatePoint(10, 10, 10)
Dim measureTools As MeasureTools
measureTools = app.MeasureTools
Dim minDist As Double
Dim Context As NameValueMap
minDist = measureTools.GetMinimumDistance( _
entity1, entity2, _
InferredTypeEnum.kNoInference, _
InferredTypeEnum.kNoInference, _
Context)
If (minDist = 0) Then
Dim point As Point
point = Context.Item(2)
Debug.Print("Minimum distance: " & minDist)
Debug.Print("Common point: [" & _
point.X & "; " & _
point.Y & "; " & _
point.Z & "]")
Else
Dim point1 As Point
point1 = Context.Item(1)
Dim point2 As Point
point2 = Context.Item(2)
Debug.Print("Minimum distance: " & minDist)
Debug.Print("Closest point on entity 1: [" & _
point1.X & "; " & _
point1.Y & "; " & _
point1.Z & "]")
Debug.Print("Closest point on entity 2: [" & _
point2.X & "; " & _
point2.Y & "; " & _
point2.Z & "]")
End If
End Sub
<
p style=”line-height: normal;margin: 0in 0in 0pt” class=”MsoNormal”>

Leave a Reply