Change fonts for section view letters

Hi,
I am new to Journals and I was wondering if someone could help me. I have some drawings where I need to change the section (also detail and projected view) view letter both on the view and on the parent view from a mixture of fonts and thicknesses to Helvet (thin). Is it possible to do this with a journal as changing each letter takes time?

Thanks,
Sonai

sorry im using NX 7.5 and I have about 10 sheets in each drawing

Try the following:


Option Strict Off
Imports System
Imports NXOpen

Module Module1

Sub Main()

Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work

If IsNothing(theSession.Parts.Work) Then
'active part required
Return
End If

Dim lw As ListingWindow = theSession.ListingWindow
lw.Open()

Dim markId1 As Session.UndoMarkId

For Each theNote As Annotations.Note In workPart.Notes

'lw.WriteLine("type: " & theNote.GetType.ToString)

Dim noteText() As String
noteText = theNote.GetText
For Each txtLine As String In noteText
'lw.WriteLine(txtLine)

If txtLine.Contains("@VWLETTER_DISP") Then 'change the font

markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Edit Object Preferences")

'get current lettering preferences
Dim letteringPreferences1 As Annotations.LetteringPreferences
letteringPreferences1 = theNote.GetLetteringPreferences()

'get font number
Dim fontIndex1 As Integer
fontIndex1 = workPart.Fonts.AddFont("helvet", FontCollection.Type.Nx)

'get current general text settings of note
Dim currentGeneralText As Annotations.Lettering
currentGeneralText = letteringPreferences1.GetGeneralText

'change desired settings
currentGeneralText.Cfw.Font = fontIndex1
currentGeneralText.Cfw.Width = Annotations.LineWidth.Thin
letteringPreferences1.SetGeneralText(currentGeneralText)

'apply new settings
theNote.SetLetteringPreferences(letteringPreferences1)

letteringPreferences1.Dispose()
Dim nErrs1 As Integer
nErrs1 = theSession.UpdateManager.DoUpdate(markId1)

Exit For

End If

Next
'lw.WriteLine("")
Next

lw.Close()

End Sub

End Module

Hi,

Thanks for that. It works but in the drawings, the letters are edited manually with edit text with . So looks like i still have to go through the drawing and remove .

I was using NX 8.5 when I wrote the code, small tweaks required for 7.5; as you have probably noticed. Sorry about that.

However, I don't understand "the letters are edited manually". How are you checking this, and how are you "fixing" them in interactive NX?

When I edit style, the font is Helvet, and if I use Edit -> annotation -> text, I see no font tags as mentioned by iamfallen.

When you say edited manually, are you saying that someone added or to the text to change the style?

If so, you could do something like I did with a regular expression. Get the note text, pass it through the function, and then put it back in the note.

Function StripModifiers(ByVal TextString As String) As String

Dim reFont1 As String = "(<)" 'Single Character "<"
Dim reFont2 As String = "(F)" 'Single Character "F"
Dim reFont3 As String = "(\d+)"'Any Integer Number
Dim reFont4 As String = "(>)" 'Single Character ">"

Dim reSize1 As String = "(<)" 'Single Character "<"
Dim reSize2 As String = "(C)" 'Single Character "C"
Dim reSize3 As String = "([+-]?\d*\.\d+)(?![-+0-9\.])" 'Floating
Dim reSize4 As String = "(>)" 'Single Character ">"

Dim reSize5 As String = "(<)" 'Single Character "<"
Dim reSize6 As String = "(C)" 'Single Character "C"
Dim reSize7 As String = "(\d+)"'Any Integer Number
Dim reSize8 As String = "(>)" 'Single Character ">"

TextString = RegEx.Replace(TextString, reFont1+reFont2+reFont3+reFont4, "")
TextString = RegEx.Replace(TextString, reSize1+reSize2+reSize3+reSize4, "")
TextString = RegEx.Replace(TextString, reSize5+reSize6+reSize7+reSize8, "")
TextString = Replace(TextString, "", "")
TextString = Replace(TextString, "", "")

Return TextString

End Function