Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.UI
Imports NXOpen.Utilities
Module report_value_of_specific_part_attribute
Dim theSession As Session = Session.GetSession()
Dim theUfSession As UFSession = UFSession.GetUFSession()
Dim lw As ListingWindow = theSession.ListingWindow()
Sub Main()
lw.Open()
Dim dispPart As Part = theSession.Parts.Display()
Dim title As String = "REV"
Dim value As String = ""
Dim charVal As Integer
Try
value = dispPart.GetStringAttribute(title)
value = value.ToUpper
Catch ex As Exception
lw.WriteLine("error: " & ex.Message)
Exit Sub
End Try
If String.IsNullOrWhiteSpace(value) Then
lw.WriteLine("revision attribute has no value")
Exit Sub
End If
If value = "ORIG" Then
Try
dispPart.SetAttribute(title, "A")
Catch ex As Exception
lw.WriteLine("error: " & ex.Message)
End Try
Else
If value.Length > 1 OrElse value < "A" OrElse value > "Z" Then
lw.WriteLine("error: invalid revision value")
Exit Sub
End If
Select Case value
Case "H", "N", "P", "T"
'skip values of "I", "O", "Q", "U"
charVal = Asc(value) + 2
value = Chr(charVal)
Case "Z"
lw.WriteLine("current revision is 'Z', modify code to allow for more revisions")
Exit Sub
Case Else
charVal = Asc(value) + 1
value = Chr(charVal)
End Select
Try
dispPart.SetAttribute(title, value)
lw.WriteLine("new revision value is: " & value)
Catch ex As Exception
lw.WriteLine("error setting attribute: " & ex.Message)
End Try
End If
End Sub
End Module