biw01
Automotive
- Dec 31, 2011
- 152
Hi All ,
How to get all the holes center points using NXOpen in a drawing file?
Regards,
Amitabh
How to get all the holes center points using NXOpen in a drawing file?
Regards,
Amitabh
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Imports System
Imports NXOpen
Imports NXOpen.Features
Imports NXOpen.UF
Public Class report_selected_hole_feature
' class members
Private Shared s As Session = Session.GetSession
Private Shared theUI As UI = UI.GetUI
Private Shared lw As ListingWindow = s.ListingWindow
Private Shared workPart As Part = s.Parts.Work
Private Shared ufs As UFSession = UFSession.GetUFSession()
Public Shared Function Main(ByVal args() As String) As Integer
lw.Open()
Dim dp As Part = s.Parts.Work
Dim featname As String
For Each feat As Feature In dp.Features
If feat.FeatureType = "HOLE PACKAGE" Then
featname = feat.GetFeatureName
lw.WriteLine("Feature type: " & feat.FeatureType _
& " Feature name: " + feat.GetFeatureName _
& " Class type: " & feat.GetType.FullName)
report_holepackage_feature(feat)
End If
Next
Return 0
End Function
Public Shared Function report_holepackage_feature(ByRef hpFeat As HolePackage) As Integer
Dim hpBuilder As HolePackageBuilder = workPart.Features.CreateHolePackageBuilder(hpFeat)
Dim hType As HolePackageBuilder.Types = hpBuilder.Type
lw.WriteLine(" Type: " & hType.ToString())
If hType = HolePackageBuilder.Types.GeneralHole Then
Dim hForm As HolePackageBuilder.HoleForms = hpBuilder.GeneralHoleForm
lw.WriteLine(" Form: " & hForm.ToString())
End If
Dim dia1 As Double = Nothing
Dim arc_data As NXOpen.UF.UFEval.Arc = Nothing
Dim cnt1 As Integer = 0
Dim bodies() As Body = hpFeat.GetBodies()
' Dim edges1() As Edge
Dim edgetype1 As Integer = Nothing
For Each bd As Body In bodies
lw.WriteLine(" Body: " & bd.ToString())
Next
Dim origins() As Point3d
Dim model_pt(2) As Double
Dim map_pt(1) As Double
Dim datapnt(1) As Double
hpFeat.GetOrigins(origins)
For Each pt As Point3d In origins
lw.WriteLine(" Origin: " & pt.ToString())
model_pt(0) = pt.X
model_pt(1) = pt.Y
model_pt(2) = pt.Z
Next
Dim exprs() As Expression = hpFeat.GetExpressions()
For Each exp As Expression In exprs
If exp.Equation.StartsWith("p") Then
lw.WriteLine(" Expression: " & exp.Equation & " " & exp.Description)
Else
lw.WriteLine("Depth = THRU Hole")
End If
Next
End Function
End Class