Get distance from hole center to solid edge

Hi I have a requirement to check distance of hole center from solid edge. How to get center of hole? I mean coordiantes of hole center. I will get bodies first, then features of the bodies. If the feature is of hole, then i need to get hole center. pls some one help me in this.

What version of NX?

Also, do you want the user to pick which edge to measure to? Or, automatically find the closest edge to the hole? Or, something else?

Version is NX 7.5 . The closest edge will be automatically picked up by the API.

lee

The following code will return the hole location and direction:


Option Strict Off
Imports System
Imports NXOpen

Module Module1

Sub Main()

Dim theSession As Session = Session.GetSession()
If IsNothing(theSession.Parts.Work) Then
'active part required
Return
End If

Dim workPart As Part = theSession.Parts.Work
Dim lw As ListingWindow = theSession.ListingWindow
lw.Open()

For Each myFeat As Features.Feature In workPart.Features
If TypeOf (myFeat) Is Features.HolePackage Then
Dim theHole As Features.HolePackage = myFeat
lw.WriteLine(".GetFeatureName: " & myFeat.GetFeatureName)
lw.WriteLine(".Location: " & myFeat.Location.ToString)
Dim holeDir() As Vector3d
theHole.GetDirections(holeDir)
lw.WriteLine("number of holes: " & holeDir.Length.ToString)
lw.WriteLine("direction of first hole: " & holeDir(0).ToString)
End If
Next

lw.Close()

End Sub

End Module