NX Database attributes remain locked in native NX after export from Teamcenter

2023-10-27T16:28:37Z
NX Open NX for Design

Summary


Details

The part has been exported from Teamcenter using 'Export Assembly from Teamcenter'.
The exported part is opened in native NX.
Under Properties in the 'Attributes' tab, the Teamcenter database attributes are still locked and unable to be edited in native NX.
Attributes such as DB_PART_NO, DB_PART_NAME, DB_PART_REV are still locked.

The database attributes should not be locked in native NX. They should be modifiable.

Solution

There is a script available to unlock attributes in native NX.
Please capture the script from this location and save it as a .vb file:
http://solutions.industrysoftware.automation.siemens.com/view.php?si=nx_api4268

  1. In NX, select ‘File-->Utilities-->Customer Defaults’.
    1. Expand ‘Gateway’ and select ‘User Attributes’.
      1. Under ‘Security’ toggle ON, 'Attribute Locking via NX Open’.
        1. OK Customer Defaults and re-start NX.
          1. Save the script from the above link location so it has a file extension .vb
            1. In NX, open the part.
              1. In the Menu, select ‘Tools-->Journal-->Play’.
                1. Select ‘Browse’ and browse to select the .vb file.
                  1. Select ‘Run’.
                    1. You may get an information window stating:UG_AllowAttributeLockingInNXOpen = True
                      1. If you move the Information window out of the way (do not close it), you should also see a pop-up dialog that lists the attributes available in the part to lock/unlock. Something similar to this...

                        12. Select the attribute you want to unlock.
                               NOTE: Select ‘More’ at the bottom if there are lots of attributes to be listed.
                        13. The information window should now report the attribute and if it is locked or unlocked. It may also throw an exception if the attribute cannot be unlocked and give an explanation. 


                        One simple selection of the listed attribute in the pop-up dialog should automatically convert the lock status of the attribute, and report its new status to the Information Window.

                        Notes

                        Here is the script that can also be copy/pasted into a text editor and saved as a .vb file:
                        ------------------------------------------------------------------------------------

                        Option Strict Off

                        Imports System

                        Imports NXOpen

                        Imports NXOpen.UF

                        Module toggle_selected_part_attribute_lock

                        Dim theSession As Session = Session.GetSession()

                        Dim ufs As UFSession = UFSession.GetUFSession()

                        Sub Main()

                        Dim workPart As Part = theSession.Parts.Work

                        Dim lockingAllowed As Boolean = _

                        theSession.OptionsManager.GetLogicalValue("UG_AllowAttributeLockingInNXOpen")

                        Echo("UG_AllowAttributeLockingInNXOpen = " & lockingAllowed.ToString)

                        If Not lockingAllowed Then

                        Echo("Cannot modify attribute lock status")

                        Echo("See File -> Utilities -> Customer Defaults -> Gateway -> User Attributes -> Security")

                        Return

                        End If

                        'NOTE: GetAttributeTitlesByType is obsolete in NX10

                        'Dim atts() As NXObject.AttributeInformation = _

                        'workPart.GetAttributeTitlesByType(NXObject.AttributeType.Any)

                        ' To work around this use GetUserAttributes instead:

                        Dim atts() As NXObject.AttributeInformation = workPart.GetUserAttributes()

                        Dim titles(atts.Length - 1) As String

                        For ii As Integer = 0 To atts.Length - 1

                        titles(ii) = atts(ii).Title

                        Next

                        Try

                        Dim title As String = ChooseOneString("Toggle lock/unlock", titles)

                        Dim locked As Boolean = Nothing

                        Do Until title Is Nothing

                        Echo("")

                        locked = workPart.GetUserAttributeLock(title, NXObject.AttributeType.Any)

                        Echo(title & " locked = " & locked.ToString)

                        Echo("Attempting to toggle lock/unlock on " & title)

                        workPart.SetUserAttributeLock(title, _

                        NXObject.AttributeType.Any, (Not locked))

                        Echo(" no exception was thrown")

                        locked = workPart.GetUserAttributeLock(title, NXObject.AttributeType.Any)

                        Echo(title & " locked = " & locked.ToString)

                        title = ChooseOneString("Toggle lock/unlock", titles)

                        Loop

                        Catch ex As NXException

                        Echo("Caught NXException " & ex.ErrorCode.ToString & ": " & ex.Message)

                        End Try

                        End Sub

                        Sub Echo(ByVal output As String)

                        theSession.ListingWindow.Open()

                        theSession.ListingWindow.WriteLine(output)

                        theSession.LogFile.WriteLine(output)

                        End Sub

                        Function ChooseOneString(ByRef prompt As String, ByRef choices() As String) As String

                        If choices.Length = 0 Then Return Nothing

                        Dim opts(13) As String

                        Dim a As Integer = 0

                        Dim ii, resp, z As Integer

                        Dim n_choices As Integer = choices.Length

                        Do

                        If (n_choices - a) < 14 Then

                        z = n_choices - a

                        Else

                        z = 14

                        End If

                        For ii = 0 To z - 1

                        opts(ii) = choices(a + ii)

                        Next

                        If ((z = 14) And ((a + z) < n_choices)) Then opts(13) = "More..."

                        ufs.Ui.LockUgAccess(UFConstants.UF_UI_FROM_CUSTOM)

                        resp = ufs.Ui.DisplayMenu(prompt, 0, opts, z)

                        ufs.Ui.UnlockUgAccess(UFConstants.UF_UI_FROM_CUSTOM)

                        Select Case resp

                        Case 1 ' Back

                        If (a = 0) Then Return Nothing

                        a = a - 13

                        Case 2 ' Cancel

                        Return Nothing

                        Case 18 ' More ...

                        If ((a + z) < n_choices) Then a = a + 13

                        Case Else ' Picked one

                        Return choices(a + resp - 5)

                        End Select

                        Loop While True

                        Return Nothing ' can't really get here

                        End Function

                        End Module

                        KB Article ID# PL8756169

                        Contents

                        SummaryDetails

                        Associated Components

                        NX Open - All Languages