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

Attributes all titles from category (VB.NET)



I'm looking for an  answer in VB.NET

I have a part with some attributes I put under one specific category, named "LCA"
Is there a way to get all the titles under this category as a string()?


Thanks in advance,


Student at University of Ghent


Accepted by topic author Laurens
‎05-09-2017 01:52 PM

Re: Attributes all titles from category (VB.NET)


Since the Category designator is held in a structure element in the AttributeInformation, I think you would need to get all of the part attributes with GetUserAttributes(), and then iterate through them to see if each one is marked with the Category that you are interested in.  (I have not tested this.)


Re: Attributes all titles from category (VB.NET)

This was indeed the solution.

Below the code that worked for me:

Dim attributeList As NXObject.AttributeInformation() = workPart.GetUserAttributes()
Dim titleList As New List(Of String)()

For Each att As NXObject.AttributeInformation In attributeList
If att.Category.Equals("CategoryName") Then

End If

Re: Attributes all titles from category (VB.NET)

Try this:


Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.NXObject
Imports NXOpen.UF

Module get_all_titles_in_a_specified_part_attribute_category

    Dim theSession As Session = Session.GetSession()

    Sub Main()

        Dim wp As Part = theSession.Parts.Work
        Dim specifiedCategory As String = "LCA"

        Dim allPartAttrInfos() As AttributeInformation = wp.GetUserAttributes()

        For Each thisAttrInfo In allPartAttrInfos
            If thisAttrInfo.Category.Equals("LCA") Then

                Echo("Title: " & thisAttrInfo.Title.ToString())
                Echo("    Value: " & thisAttrInfo.StringValue.ToString())
                Echo("    Category: " & thisAttrInfo.Category.ToString())
                Echo(" ")
            End If

    End Sub

    Sub Echo(ByVal output As String)


    End Sub

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

End Module

Re: Attributes all titles from category (VB.NET)

I'm glad you got it to work - I think we were posting simultaneously.  8-)


Re: Attributes all titles from category (VB.NET)

[ Edited ]

Yes, I think so too.
Thank you for your help. Smiley Happy
May I ask what "Echo" does in your code? I'm not familiar with that command.

Re: Attributes all titles from category (VB.NET)

It is a very small subroutine that is used to send the output to both the information window and the NX syslog.  You will see it in a lot of the example programs that we post on the Solution Center.