cancel
Showing results for 
Search instead for 
Did you mean: 

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

Valued Contributor
Valued Contributor
 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

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

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
Ganesh Kadole, QA Analyst (PLM), SQS
Testing: NX 10 | NX 11 | TCIN
TC 11.2 | TC Vis 11.3 | AWC 3.2