Showing results for 
Search instead for 
Did you mean: 

Mass updating part file attributes


Hi -

Currently we have an attribute in the NX part file called:



We need 2 Attributes added to the part file called:




The value for these 2 new attributes ideally would be copied from the existing DESCRIPT value (if there) or if not , then any value be placed into it (like a – for example), but the 2 new attributes need a value.


Looking for a way to have these 2 new attributes and values placed in during a batch update (or anyway to get around from opening every file).


I did spot check some of the data and noticed that not all files have the DESCRIPT in it, so to be safe I would suppose the second option would be the safest bet to give a generic value that would be updated later.


anyone have any suggestions on this approach?




Re: Mass updating part file attributes


Lately NX has greatly enhanced its Bulk Editing of file properties capability. I’m not sure if NX7.5 offers this following function:

Add the new Attributes to a component or to some components to be edited. (Assume you have done it)

Open the assembly and with the selection “Components” press “Ctrl+A” to select all the components you want to edit Properties.

RMB a highlighted component and select “Properties”

In the Attribute tab, change the two pulldown selections to “Bulk Edit” and “Part”.

Click the column header (=DESCRIPT) and copy to clipboard (Ctrl+C).

Click the New Attribute column header and paste (Ctrl+V)

Edit any values as you wish to appear in Attributes.

Press OK.

Save All.

I hope this is what you are looking for.

Michael Fernando

Die Designer

Re: Mass updating part file attributes

Actually I was looking more of an automated (program) way to update 27,000 files without having to open the file at all. Something more like the refile commanded NX has when needing to update the version of files that have not been opened in NX for a few releases.
Best Regards/ Mit freundlichen Grüßen,
Marc Sotak
IT PLM CAD Analyst ~ Regional ShS Americas
Bendix Commercial Vehicle Systems LLC
901 Cleveland St.
Elyria, Ohio 44035
Phone: (440) 329-9116
Fax: (440) 329-9580
Bendix is growing. Join Us as we drive the future.

This transmission is intended solely for the addressee and contains confidential information.
If you are not the intended recipient, please immediately inform the sender and delete the message and any attachments from your system.
Furthermore, please do not copy the message or disclose the contents to anyone unless agreed otherwise. To the extent permitted by law we shall in no way be liable for any damages, whatever their nature, arising out of transmission failures, viruses, external influence, delays and the like.

Re: Mass updating part file attributes

Siemens Phenom Siemens Phenom
Siemens Phenom

Sounds like a fairly simple NX/Open or SNAP application. You'll probably get a good answer in the Customization/Programming forum.


Re: Mass updating part file attributes

Here is a simple journal that you run using

run_journal  NX75Attributer.vb   -args  C:\Your\Full\Path\To\NXPartFiles

You need to run this from a command  prompt and you have saved the journal as NX75Attributer.vb.  I suggest you place the journal in UGII\Managed directory.


Option Strict Off
Imports System
Imports System.Collections
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.Utilities

Module batch_process_attributes_in_each_part_in_specified_directory
    Dim theSession As Session = Session.GetSession()
    Dim ufs As UFSession = UFSession.GetUFSession()
    Dim lw As ListingWindow = theSession.ListingWindow

    Sub Main(ByVal args As String())
            Dim theDirectory As String = args(0)
            lw.WriteLine("Directory to process: " & theDirectory)
            lw.WriteLine(" ")
            Dim partFlag As Integer = 0
            For Each fileName As String In My.Computer.FileSystem.GetFiles(theDirectory)
                Dim extension As String = Right$(fileName, 4).ToLower()
                If extension = ".prt" Then
                    partFlag = open_part_file(fileName)
                End If
                If partFlag > 0 Then
                    ' Some parts failed to open.
                    ' Take appropriate action here
                End If
                ' Close any open part files
                Dim partCount As Integer = ufs.Part.AskNumParts()
                If partCount > 0 Then
                    theSession.Parts.SaveAll(BasePart.CloseModified.CloseModified, Nothing)
                    lw.WriteLine("  ")
                End If
        Catch ex As Exception
        End Try
    End Sub

    Private Sub process_each_part(ByVal thePart As Part)
        Dim isfound As Boolean = False
        ' find if DESCRIPT attributes exist
        Dim DESCRIPTattrName As String = "DESCRIPT"
        Dim DESCRIPTattrVal As String = Nothing
        Dim KB_DESCRIPTION_ENattrName As String = "KB_DESCRIPTION_EN"
        Dim KB_DESCRIPTION_ENattrVal As String = Nothing
        Dim KB_DESCRIPTION_NATIVEattrVal As String = Nothing
        isfound = find_part_attr_by_name(thePart, DESCRIPTattrName, DESCRIPTattrVal)
        If isfound = True Then
            KB_DESCRIPTION_ENattrVal = DESCRIPTattrVal
            KB_DESCRIPTION_NATIVEattrVal = DESCRIPTattrVal
            thePart.SetAttribute(KB_DESCRIPTION_ENattrName, KB_DESCRIPTION_ENattrVal)
            thePart.SetAttribute(KB_DESCRIPTION_NATIVEattrName, KB_DESCRIPTION_NATIVEattrVal)
            DESCRIPTattrVal = "-"
            KB_DESCRIPTION_ENattrVal = "-"
            KB_DESCRIPTION_NATIVEattrVal = "-"
            thePart.SetAttribute(DESCRIPTattrName, DESCRIPTattrVal)
            thePart.SetAttribute(KB_DESCRIPTION_ENattrName, KB_DESCRIPTION_ENattrVal)
            thePart.SetAttribute(KB_DESCRIPTION_NATIVEattrName, KB_DESCRIPTION_NATIVEattrVal)
        End If
    End Sub

    Public Function open_part_file(ByVal fileName As String) As Integer
        Dim loadStatus As NXOpen.PartLoadStatus = Nothing
        Dim currentPart As Part = _
             theSession.Parts.OpenBaseDisplay(fileName, loadStatus)
        If loadStatus.NumberUnloadedParts < 1 Then
            lw.WriteLine("   Processing Part File: " & fileName)
            For inx As Integer = 0 To loadStatus.NumberUnloadedParts - 1
                Dim errno As Integer = CInt(loadStatus.GetStatus(inx))
                Dim errmsg As String = ""
                ufs.UF.GetFailMessage(errno, errmsg)
                lw.WriteLine("  ")
        End If
        Return loadStatus.NumberUnloadedParts()
    End Function

    Public Function find_part_attr_by_name(ByVal thePart As Part, _
                                     ByVal attrName As String, _
                                     ByRef attrVal As String) As Boolean
        Dim theAttr As Attribute = Nothing
        Dim attr_info() As NXObject.AttributeInformation
        attr_info = thePart.GetAttributeTitlesByType(NXObject.AttributeType.String)
        Dim title As String = ""
        Dim value As String = ""
        Dim inx As Integer = 0
        Dim count As Integer = attr_info.Length()
        If attr_info.GetLowerBound(0) < 0 Then
            Return False
        End If
        Do Until inx = count
            Dim result As Integer = 0
            title = attr_info(inx).Title.ToString
            result = String.Compare(attrName, title)
            If result = 0 Then
                attrVal = thePart.GetStringAttribute(title)
                Return True
            End If
            inx += 1
        Return False
    End Function
End Module

I took this from existing sample programs and simply substituted the attribute parts.



Frank Swinkels

Re: Mass updating part file attributes


This is awesome. Exactly what I need. Thank you.