Access

Hello,

I need to access a Note in a drawing, but it have a follow name: C:TC7R0.

When I use the command getstringattribute, my code don't work.

workPart.GetStringAttribute("C:TC7R0")

Anyone help me, please?

Tks in advance.

Object names and attributes are two fundamentally different things. If you have given the note a name, you will not be able to retrieve the note object with the .GetStringAttribute method.

First we need to determine if "C:TC7R0" represents an object name or an attribute title. Right click on your note and choose "properties"; if you find "C:TC7R0" on the attributes tab then it is an attribute, if you find "C:TC7R0" on the general tab, then it is an object name.

If "C:TC7R0" is an attribute, you will need to use the correct methods to get the attribute value. The correct method to use will depend on what version of NX you are running.

If "C:TC7R0" is the name of the note, you can iterate through the part's note collection until you find the note with the given name.

What version of NX are you using?

Nx 9

W. Yamada

Does "C:TC7R0" represent an object name or attribute title?

Name

W. Yamada

In that case, you can iterate through the note collection looking for the note with the given name.

Dim myNote As Annotations.Note

For Each temp As Annotations.Note In workPart.Notes
If temp.Name = "C:TC7R0" Then
myNote = temp
Exit For
End If
Next

'do something with myNote

First... Thank you so much for your help.

I tested the code but the value that is returned is not the same as is the note...

W. Yamada

What value did you expect and what value was returned?
Is there more than one note with the same name?

The note C:TC7R0 = "tool", the returned value is Note 43311...

I used the messagebox only to show the value... but I want to show "tool".

W. Yamada

You can use the note object's .GetText method. This will return a string array; each item in the array represents a line in the note.

Could you explain using the code as example, please?

W. Yamada

The code below shows how to get the text and writes it to the listing window. You will need to have a reference to the listing window already, this code assumes the reference to the listing window is named "lw".

Dim myNote As Annotations.Note = Nothing

For Each temp As Annotations.Note In workPart.Notes
If temp.Name = "C:TC7R0" Then
myNote = temp
Exit For
End If
Next

If IsNothing(myNote) Then
'note not found
Return
End If

Dim noteText() As String = myNote.GetText

For Each textLine As String In noteText
lw.writeline(textLine)
Next

Hello,

In my drawing there are 2 notes with the same name... I need to show the both values...

W. Yamada

Create an array, or better yet a list, to hold the named notes. Iterate through the notes collection as before, when you find one with the given name, add it to the list. When you are done iterating through the collection, the list will hold all the notes with the given name.