Hello,
Below is code which is available in this site, it is working fine suppose when i am replacing word ABC with XYZ, but not working when same word ABC is attached with leader, can you please help, Thanks in advance
below is code :
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpenUI
Imports NXOpen.Utilities
Imports NXOpen.Annotations
Module ChangeNoteWord
Sub Main()
Dim s As Session = Session.GetSession()
Dim dp As Part = s.Parts.Display
Dim nc As NoteCollection = dp.Notes
Dim notetext1 As String = "CURRENT WORD"
notetext1 = NXInputBox.GetInputString("Change Note", "Note word to be changed", notetext1)
Dim notetext2 As String = "REPLACEMENT WORD"
notetext2 = NXInputBox.GetInputString("Change Note", "New note word", notetext2)
Dim notestring() As String
Dim nolines As Integer = 0
Dim found1 As Boolean = False
Dim m1 As Session.UndoMarkId = s.SetUndoMark(Session.MarkVisibility.Visible, "M1")
For Each a_note As SimpleDraftingAid In nc
notestring = a_note.GetText()
nolines = notestring.Length
For i As Integer = 0 To nolines - 1
found1 = notestring(i).Contains(notetext1)
If found1 = True Then
notestring(i) = notestring(i).Replace(notetext1, notetext2)
End If
Next
a_note.SetText(notestring)
Next
s.UpdateManager.DoUpdate(m1)
End Sub
Public Function GetUnloadOption(ByVal dummy As String) As Integer
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
End Function
End Module
re: note with leader
When you add a bit of text to the drawing, it is considered a "Note" object and can be found in the part's .Notes collection. For reasons that I don't fully understand, when you add a leader to a Note, it becomes a "Label" and gets moved to the part's .Labels collection. If you are looking for text in a note or label, you will need to search both the .Notes and .Labels collections.
Thank you for your quick
Thank you for your quick response and clarifying my doubt, it worked when i changed .Notes collection to .Labels collection, Thank you so much