Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get all hole center points in a drawing using NXopen ?

Status
Not open for further replies.

biw01

Automotive
Dec 31, 2011
152
US
Hi All ,

How to get all the holes center points using NXOpen in a drawing file?

Regards,
Amitabh
 
Replies continue below

Recommended for you

Why NXOpen?

maybe this can also helpfull
turn on the new NX6 Hole Table creation in drafting
set the variable UGII_DRAFTING_HOLE_TABLE=1

Then you can use "Insert/Table/ Hole Table..."

best regards!
 
Thanks for the information.
I need to add notes to the holes in the drawing using NX open code.
Hence i wish to retrieve the center points of each of the holes in the drawing with respect to the drawing co-ordinate system.

Regards
 
Hi biw01,

This is more complicated than you might think. I had designed some software for a client who had the same wishes.

There are multiple points you need to consider:

[ol 1]
What exactly is a "hole"? This is a vague term; NX works with features. Therefore, a SUBTRACT feature with a cylindrical form could be considered a hole. So are holes created with the NX hole feature, which consequently have their own types. In addition, you might have to think about holes created using instance geometries, holes created in circular / linear patterns, hole series, etc..
[/ol]
[ol 2]
Most features (not ALL!) have locations. SUBTRACT features, for example, do not. In this case you will need to determine the circular edges which belong to this feature, for example.
[/ol]
[ol 3]
From your hole locations you will need to map them to the view for which you want to create the labels.
[/ol]


Marc
NX Software Developer
 
Here is a journal (part of a larger program) which give all info including hole centres for HolePackage feature. Hope this gets you strarted.

Code:
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

Regards

Frank Swinkels
 
Thanks Frank , i will try this code snippet and will let you know if i need more help.

Thanks once again.

Amitabh
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top