Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Hole Series w/NX Open

Status
Not open for further replies.

pcalonzi2

Mechanical
Feb 1, 2013
18
Does anyone have any experience with modifying Hole Series between components in NX/Open. From an assembly, I am trying to determine what the component parts are referenced by the Hole Series.

Thank you,
-Pat

Thank you,
-Pat
 
Replies continue below

Recommended for you

I have found this command: GetHoleSeriesStartHoleFeature but can't seem to get it to work...
-Pat

Thank you,
-Pat
 
Here is some code that may get you started; open an assembly that has at least 1 hole series feature and run the journal. It will list the hole series feature and the components used in that hole series feature.

Code:
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.Features


Module Module1

    Sub Main()

        Dim theSession As Session = Session.GetSession()
        Dim workPart As Part = theSession.Parts.Work

        Dim lw As ListingWindow = theSession.ListingWindow
        lw.Open()

        Dim featArray() As Feature = theSession.Parts.Work.Features.GetFeatures()

        For Each myFeature As Feature In featArray

            If myFeature.FeatureType.ToUpper = "HOLE ORCHESTRATION" Then

                lw.WriteLine("feature: " & myFeature.GetFeatureName)

                Dim holeSeries As HolePackage = myFeature
                Dim holeBuilder As HolePackageBuilder
                holeBuilder = workPart.Features.CreateHolePackageBuilder(holeSeries)

                Dim startBodies() As Body
                startBodies = holeBuilder.StartHoleData.BooleanOperation.GetTargetBodies()

                Dim middleBodies() As Body
                middleBodies = holeBuilder.MiddleHoleData.BooleanOperation.GetTargetBodies

                Dim endBodies() As Body
                endBodies = holeBuilder.EndHoleData.BooleanOperation.GetTargetBodies

                lw.WriteLine("start body component: " & startBodies(0).OwningComponent.Name & " (" & startBodies(0).Prototype.OwningPart.FullPath & ")")

                For Each tempBody As Body In middleBodies
                    lw.WriteLine("middle body component: " & tempBody.OwningComponent.Name & " (" & tempBody.Prototype.OwningPart.FullPath & ")")
                Next

                lw.WriteLine("end body component: " & endBodies(0).OwningComponent.Name & " (" & endBodies(0).Prototype.OwningPart.FullPath & ")")

            End If
        Next

        lw.WriteLine("")
        lw.Close()


    End Sub


    Public Function GetUnloadOption(ByVal dummy As String) As Integer

        'Unloads the image when the NX session terminates
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination

    End Function

End Module

www.nxjournaling.com
 
Thanks Cowski,

I got this working but now another question lets say that the startbody is your work part, you have a linked hole feature in the browser. How can you figure out the parent feature/part would be?

-Pat

Thank you,
-Pat
 
Try the code below...

Code:
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.Features
Imports NXOpen.UF


Module Module1

    Sub Main()

        Dim theSession As Session = Session.GetSession()
        Dim workPart As Part = theSession.Parts.Work
        Dim theUFSession As UFSession = UFSession.GetUFSession

        Dim lw As ListingWindow = theSession.ListingWindow
        lw.Open()

        Dim featArray() As Feature = theSession.Parts.Work.Features.GetFeatures()

        For Each myFeature As Feature In featArray
            'lw.WriteLine(myFeature.GetFeatureName)
            'lw.WriteLine(myFeature.FeatureType)
            'lw.WriteLine("")

            If myFeature.FeatureType.ToUpper = "HOLE ORCHESTRATION" Then

                lw.WriteLine("feature: " & myFeature.GetFeatureName)

                Dim holeSeries As HolePackage = myFeature
                Dim holeBuilder As HolePackageBuilder
                holeBuilder = workPart.Features.CreateHolePackageBuilder(holeSeries)

                Dim startBodies() As Body
                startBodies = holeBuilder.StartHoleData.BooleanOperation.GetTargetBodies()

                Dim middleBodies() As Body
                middleBodies = holeBuilder.MiddleHoleData.BooleanOperation.GetTargetBodies

                Dim endBodies() As Body
                endBodies = holeBuilder.EndHoleData.BooleanOperation.GetTargetBodies

                lw.WriteLine("start body component: " & startBodies(0).OwningComponent.Name & " (" & startBodies(0).Prototype.OwningPart.FullPath & ")")

                For Each tempBody As Body In middleBodies
                    lw.WriteLine("middle body component: " & tempBody.OwningComponent.Name & " (" & tempBody.Prototype.OwningPart.FullPath & ")")
                Next

                lw.WriteLine("end body component: " & endBodies(0).OwningComponent.Name & " (" & endBodies(0).Prototype.OwningPart.FullPath & ")")

            End If

            If myFeature.FeatureType.ToUpper = "LINKED HOLE PACKAGE" Then
                lw.WriteLine("linked hole package found")
                Dim sourceTag As Tag
                Dim linkBroken As Boolean = True
                theUFSession.Wave.IsLinkBroken(myFeature.Tag, linkBroken)
                If linkBroken Then
                    lw.WriteLine("link to parent geometry is broken")
                Else
                    theUFSession.Wave.AskLinkSource(myFeature.Tag, True, sourceTag)
                    If sourceTag = Tag.Null Then
                        lw.WriteLine("could not fully load parent file...")
                    Else
                        Dim myTaggedObj As TaggedObject
                        Dim sourceFeature As HolePackage
                        Dim sourceFile As Part
                        myTaggedObj = theSession.GetObjectManager.GetTaggedObject(sourceTag)
                        sourceFeature = myTaggedObj
                        sourceFile = sourceFeature.OwningPart
                        lw.WriteLine("parent file: " & sourceFile.FullPath)
                        lw.WriteLine("parent feature: " & sourceFeature.GetFeatureName)

                    End If

                End If

            End If

        Next

        lw.WriteLine("")
        lw.Close()


    End Sub


    Public Function GetUnloadOption(ByVal dummy As String) As Integer

        'Unloads the image when the NX session terminates
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination

    End Function

End Module

www.nxjournaling.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor