Showing results for 
Search instead for 
Do you mean 
Reply
Solved! Go to solution

Get a list of all available attributes for Part in an Assembly

 For Each child As Component In dispPart.ComponentAssembly.RootComponent.GetChildren()
             child.GetStringUserAttribute("Attribute Name as String", 1)
 Next

The code above I use to get a specific value of an attribute, given that I know the name of the attribute I want to get.  Is it possible to get a list of all of the all available attributes ?

 

 

1 REPLY
Solution
Solution
Accepted by topic author ulink2rle
‎03-08-2017 04:42 PM

Re: Get a list of all available attributes for Part in an Assembly

[ Edited ]

For specific components in an assembly?

 

Following is the journal which report the attributes of selected objects.

 

Option Strict Off
Imports System
Imports NXOpen

Module NXJournal

    Dim theSession As Session = Session.GetSession()

    Sub Echo(ByVal output As String)
        theSession.ListingWindow.Open()
        theSession.ListingWindow.WriteLine(output)
        theSession.LogFile.WriteLine(output)
    End Sub

    Sub ReportNXObjectAttributes(ByVal obj As NXObject)

        Dim aI As NXObject.AttributeInformation() = obj.GetUserAttributes
        Dim aV As String() = obj.GetUserAttributesAsStrings()

        If String.IsNullOrEmpty(obj.Name) Then
            Echo(obj.ToString() & " has " & aI.Length & " attributes")
        Else
            Echo(obj.Name & " has " & aI.Length & " attributes")
        End If

        For ii As Integer = 0 To aI.Length - 1
            If aI(ii).Array Then
                Echo("  " + aI(ii).Title & "(" & aI(ii).ArrayElementIndex & ") = " & aV(ii) & " (" & aI(ii).Type.ToString() & ")")
            Else
                Echo("  " + aI(ii).Title & " = " & aV(ii) & " (" & aI(ii).Type.ToString() & ")")
            End If
        Next

    End Sub

    Sub Main()

        Dim theSelection As Selection = UI.GetUI().SelectionManager

        For ii As Integer = 0 To theSelection.GetNumSelectedObjects() - 1
            ReportNXObjectAttributes(theSelection.GetSelectedTaggedObject(ii))
        Next

    End Sub

End Module
Testing NX10 | NX11| TC-NX Integration
Teamcenter 11.2 | TC Vis 11.3 | Active Workspace 3.2