Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

Check supprestion state component in arrangement in assembky 1

Status
Not open for further replies.

MANox

Mechanical
Apr 2, 2007
117
0
0
PL
Hello,

I have problem with check which components are suppressed in active arrangement in assembly.
I try with this, but without positive results:
Code:
Imports NXOpen.UF
Imports NXOpen.Assemblies
Imports NXOpen.Assemblies.Component

Module Arrangement_tester

    Dim arrtheSession As Session = Session.GetSession()
    Dim workPart As Part = arrtheSession.Parts.Work
    Dim displayPart As Part = arrtheSession.Parts.Display
    Dim startWorkPart As Part = arrtheSession.Parts.Work
    Dim startDispPart As Part = arrtheSession.Parts.Display

    Public ufs As UFSession = UFSession.GetUFSession()
    Public lw As ListingWindow = arrtheSession.ListingWindow

    Sub Main()
        Dim startWorkPart As Part = arrtheSession.Parts.Work
        Dim startDispPart As Part = arrtheSession.Parts.Display

        lw.Open()
        Try
            Dim c As ComponentAssembly = displayPart.ComponentAssembly
            Dim activeArr As Arrangement
            activeArr = c.ActiveArrangement

            For Each child As Component In c.RootComponent.GetChildren()
                Dim IsSuppresed As Boolean
                c.GetSuppressedState(child, activeArr, IsSuppresed)
                If Not IsSuppresed Then
                    lw.WriteLine(child.DisplayName & " is suppresed")
                End If
            Next
        Catch e As Exception
            arrtheSession.ListingWindow.WriteLine("Failed: " & e.ToString)
        End Try
        lw.Close()

    End Sub
    Public Function GetUnloadOption(ByVal dummy As String) As Integer
        Return Session.LibraryUnloadOption.Immediately
    End Function

End Module

Maybe someone could find fault in my code or show me right way to success.

Best regards

MANok
NX2027
TC14
 
Replies continue below

Recommended for you

I have not run your code, but this part stuck out to me:
Code:
If [highlight #FCE94F]Not IsSuppresed[/highlight] Then
    lw.WriteLine(child.DisplayName & " [highlight #FCE94F]is suppresed[/highlight]")
End If

www.nxjournaling.com
 
I had a look at the .GetSuppressedState method; the boolean argument only tells you whether the suppression is controlled by the arrangement or not. The return value will tell you if the component is suppressed or not.

Code:
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.Assemblies
Imports NXOpen.Assemblies.Component

Module Arrangement_tester

    Dim arrtheSession As Session = Session.GetSession()
    Dim workPart As Part = arrtheSession.Parts.Work
    Dim displayPart As Part = arrtheSession.Parts.Display
    Dim startWorkPart As Part = arrtheSession.Parts.Work
    Dim startDispPart As Part = arrtheSession.Parts.Display

    Public ufs As UFSession = UFSession.GetUFSession()
    Public lw As ListingWindow = arrtheSession.ListingWindow

    Sub Main()
        Dim startWorkPart As Part = arrtheSession.Parts.Work
        Dim startDispPart As Part = arrtheSession.Parts.Display

        lw.Open()
        Try
            Dim c As ComponentAssembly = displayPart.ComponentAssembly
            Dim activeArr As Arrangement
            activeArr = c.ActiveArrangement

            For Each child As Component In c.RootComponent.GetChildren()
                Dim IsSuppresed As Boolean
                Dim theSuppressedState As ComponentAssembly.SuppressedState
                theSuppressedState = c.GetSuppressedState(child, activeArr, IsSuppresed)
                lw.WriteLine(child.DisplayName & " suppressed state: " & theSuppressedState.ToString)
                If IsSuppresed Then
                    lw.WriteLine(child.DisplayName & " suppression is controlled by arrangement")
                Else
                    lw.WriteLine(child.DisplayName & " suppression is NOT controlled by arrangement")
                End If
                lw.WriteLine("")
            Next
        Catch e As Exception
            arrtheSession.ListingWindow.WriteLine("Failed: " & e.ToString)
        End Try
        lw.Close()
    End Sub
    Public Function GetUnloadOption(ByVal dummy As String) As Integer
        Return Session.LibraryUnloadOption.Immediately
    End Function

End Module

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