How to get component name from general tab of component properties?

Is anyone able to explain to me how to get the component name from the general tab of the component properties?

Right click on a Component
Select "Properties"
Select "General" tab
I am trying to access that name. Any help is greatly appreciated.

{component reference}.Name

I have tried that and cannot get the proper output. I grab a component assembly from the workpart, and sort through it's children, and print their names(and I've tried a magnitude of variations), but they never print any of the changes I make in the General tab properties.

DHuskic
Nx 9 VB

Do the names show up as expected in the assembly navigator? You may have to turn on the "component name" column to see them. Is the top level assembly the display part when you are assigning these component names?

Yes, they show up as expected in the component name column and the top level assembly is the display part. Here is the code I was using for this operation:

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

Module Names
Public theSession As Session = Session.GetSession()
Public theUFSession As UFSession = UFSession.GetUFSession()
Public Lw As ListingWindow = theSession.ListingWindow

Sub Main()
Lw.Open()
Lw.writeline("First Process")
For Each comp As Component In theSession.Parts.Work.ComponentAssembly.RootComponent.GetChildren
Dim partName As String = ""
Dim refsetName As String = ""
Dim instanceName As String = ""
Dim origin(2) As Double
Dim csysMatrix(8) As Double
Dim transform(3, 3) As Double
theUFSession.Assem.AskComponentData(comp.Tag, partName, refsetName, instanceName, origin, csysMatrix, transform)

Dim partNumber As String = ""
partNumber = instanceName & "Rev1"
Dim thisInstance As NXOpen.Tag = theUFSession.Assem.AskInstOfPartOcc(comp.Tag)

Lw.WriteLine("PartName: " & partName)
Lw.WriteLine("RefsetName: " & refsetName)
Lw.WriteLine("InstanceName: " & instanceName)

' this changes what shows up in Component Properties->General->Name
theUFSession.Obj.SetName(comp.Tag, partNumber)

' uncomment the following line to change the instance name
theUFSession.Assem.RenameInstance(thisInstance, partNumber)
Next

Lw.writeline("Second Process")
For Each Obj As DisplayableObject In theSession.Parts.Display.Views.WorkView.AskVisibleObjects
Dim comp As Component = Obj.OwningComponent

'ChangeWorkPart(Obj.OwningComponent)
Dim partName As String = ""
Dim refsetName As String = ""
Dim instanceName As String = ""
Dim origin(2) As Double
Dim csysMatrix(8) As Double
Dim transform(3, 3) As Double
theUFSession.Assem.AskComponentData(comp.Tag, partName, refsetName, instanceName, origin, csysMatrix, transform)

Dim partNumber As String = ""
partNumber = instanceName & "Modified"
Dim thisInstance As NXOpen.Tag = theUFSession.Assem.AskInstOfPartOcc(comp.Tag)

'Debug - output new name
Lw.WriteLine("PartName: " & partName)
Lw.WriteLine("RefsetName: " & refsetName)
Lw.WriteLine("InstanceName: " & instanceName)

' this changes what shows up in Component Properties->General->Name
theUFSession.Obj.SetName(comp.Tag, partNumber)

' uncomment the following line to change the instance name
theUFSession.Assem.RenameInstance(thisInstance, partNumber)
Next
End Sub
End Module

The first process does not read the name from the component that I would expect, but the second process does. I attempted using the prototype, owningPart, and owningComponent(and combinations of each) with the .Name, .Lead, .DisplayName, and any other properties I thought might be helpful but it appears it is not a proper method for referencing the work component in an assembly.

Most assemblies we use are multi-levels, but for testing purposes, I had an assembly file with 1 parent and multiple children for this code. Do you know how I might be able to reference the work component properly?

DHuskic
Nx 9 VB

The following seems to work in NX 9, does it give the expected results in NX 7.5?

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

Module Names
Public theSession As Session = Session.GetSession()
Public theUFSession As UFSession = UFSession.GetUFSession()
Public Lw As ListingWindow = theSession.ListingWindow

Sub Main()
Lw.Open()
'Lw.writeline("First Process")
For Each comp As Component In theSession.Parts.Work.ComponentAssembly.RootComponent.GetChildren

lw.writeline("component name: " & comp.Name)
comp.SetName(comp.Name & "_rev1")
lw.writeline("new component name: " & comp.Name)
lw.writeline("ref set name: " & comp.referenceset)
lw.writeline("component part name: " & comp.Prototype.OwningPart.fullpath)
lw.writeline("")

Next

End Sub
End Module

That works perfectly. Not sure what issues I was having earlier as to why it wouldn't read the component correctly(I was probably referencing the component correctly. Thanks for the help.

DHuskic
Nx 9 VB