Change font for "Label On Parent" in Drafting

Hi.

I'm trying to create a journal that changes all fonts for every drafting object in the drawing to Arial (among other things).
So far everything changes except "label on parent". I can't figure out how to change the font for those. If anyone could help me find a code that selects all the label on parents in the drawing and then change their font to Arial that would be much appreciated. I'm running NX8.5 and this is my code so far:

Thank you!

Option Strict Off

Imports System
Imports System.Collections.Generic
Imports NXOpen
Imports NXOpen.UF
Module set_dim_text_to_arial

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

Sub Main()

Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "change dim text to Arial")

'Load Drafting Standards

Dim loadDraftingStandardBuilder1 As Preferences.LoadDraftingStandardBuilder
loadDraftingStandardBuilder1 = workPart.Preferences.DraftingPreference.CreateLoadDraftingStandardBuilder()

loadDraftingStandardBuilder1.WelcomeMode = False

loadDraftingStandardBuilder1.Level = Preferences.LoadDraftingStandardBuilder.LoadLevel.Site

loadDraftingStandardBuilder1.Name = "FMC_KBG"

Dim nXObject1 As NXObject
nXObject1 = loadDraftingStandardBuilder1.Commit()

loadDraftingStandardBuilder1.Destroy()

'Version up drafting objects

workPart.Drafting.VersionUpAllDraftingObjects()

'Declare Font type

Dim fntArial As Integer = workPart.Fonts.AddFont("Arial", FontCollection.Type.Standard)

'Declare Aspect Ratio

Dim ratio As String = 1

'Change GD&T Settings

For Each tempGdts As Annotations.Gdt In workPart.Gdts

Dim symbolPreferences1 As Annotations.SymbolPreferences
symbolPreferences1 = tempGdts.GetSymbolPreferences()

Dim lineAndArrowPreferences1 As Annotations.LineAndArrowPreferences
lineAndArrowPreferences1 = tempGdts.GetLineAndArrowPreferences()

Dim letteringPreferences1 As Annotations.LetteringPreferences
letteringPreferences1 = tempGdts.GetLetteringPreferences()

Dim generalText1 As Annotations.Lettering
generalText1.Size = 3.5
generalText1.CharacterSpaceFactor = 0.0
generalText1.AspectRatio = ratio
generalText1.LineSpaceFactor = 1.0
generalText1.Cfw.Color = 37
generalText1.Cfw.Font = fntArial
generalText1.Cfw.Width = Annotations.LineWidth.Thin
generalText1.Italic = False
letteringPreferences1.SetGeneralText(generalText1)

tempGdts.SetLetteringPreferences(letteringPreferences1)

letteringPreferences1.Dispose()
lineAndArrowPreferences1.Dispose()
symbolPreferences1.SetWeldSpaceFactor(2.0)

symbolPreferences1.SetWeldSymbolSizeFactor(1.0)

Dim weldSymbolCfw1 As Annotations.LineCfw = New Annotations.LineCfw(37, DisplayableObject.ObjectFont.Solid, Annotations.LineWidth.Thin)
symbolPreferences1.SetWeldSymbolCfw(weldSymbolCfw1)

Dim surfaceFinishCfw1 As Annotations.LineCfw = New Annotations.LineCfw(37, DisplayableObject.ObjectFont.Solid, Annotations.LineWidth.Thin)
symbolPreferences1.SetSurfaceFinishCfw(surfaceFinishCfw1)

symbolPreferences1.DraftingSurfaceFinishStandard = Annotations.SurfaceFinishStandard.Iso2002

symbolPreferences1.WeldSymbolStandard = Annotations.WeldStandard.Iso

tempGdts.SetSymbolPreferences(symbolPreferences1)

symbolPreferences1.Dispose()
tempGdts.LeaderOrientation = Annotations.LeaderOrientation.FromLeft

Dim nErrs1 As Integer

Next

'Change Note Settings

For Each tempNote As Annotations.Note In workPart.Notes

Dim lineAndArrowPreferences1 As Annotations.LineAndArrowPreferences
lineAndArrowPreferences1 = tempNote.GetLineAndArrowPreferences()

Dim letteringPreferences1 As Annotations.LetteringPreferences
letteringPreferences1 = tempNote.GetLetteringPreferences()

Dim generalText1 As Annotations.Lettering
generalText1.Size = 3.5
generalText1.CharacterSpaceFactor = 0.0
generalText1.AspectRatio = ratio
generalText1.LineSpaceFactor = 1.0
generalText1.Cfw.Color = 37
generalText1.Cfw.Font = fntArial
generalText1.Cfw.Width = Annotations.LineWidth.Thin
generalText1.Italic = False
letteringPreferences1.SetGeneralText(generalText1)

tempNote.SetLetteringPreferences(letteringPreferences1)

letteringPreferences1.Dispose()
lineAndArrowPreferences1.Dispose()

Next

'Change Label Settings

For Each tempLabel As Annotations.Label In workPart.Labels

Dim lineAndArrowPreferences1 As Annotations.LineAndArrowPreferences
lineAndArrowPreferences1 = tempLabel.GetLineAndArrowPreferences()

Dim letteringPreferences1 As Annotations.LetteringPreferences
letteringPreferences1 = tempLabel.GetLetteringPreferences()

Dim generalText1 As Annotations.Lettering
generalText1.Size = 3.5
generalText1.CharacterSpaceFactor = 0.0
generalText1.AspectRatio = ratio
generalText1.LineSpaceFactor = 1.0
generalText1.Cfw.Color = 37
generalText1.Cfw.Font = fntArial
generalText1.Cfw.Width = Annotations.LineWidth.Thin
generalText1.Italic = False
letteringPreferences1.SetGeneralText(generalText1)

tempLabel.SetLetteringPreferences(letteringPreferences1)

letteringPreferences1.Dispose()
lineAndArrowPreferences1.Dispose()

Next

'Change Weld Symbol Settings

For Each tempWeldSymbol As Annotations.Weld In workPart.Annotations.Welds

Dim lineAndArrowPreferences1 As Annotations.LineAndArrowPreferences
lineAndArrowPreferences1 = tempWeldSymbol.GetLineAndArrowPreferences()

Dim letteringPreferences1 As Annotations.LetteringPreferences
letteringPreferences1 = tempWeldSymbol.GetLetteringPreferences()

Dim generalText1 As Annotations.Lettering
generalText1.Size = 3.5
generalText1.CharacterSpaceFactor = 0.0
generalText1.AspectRatio = ratio
generalText1.LineSpaceFactor = 1.0
generalText1.Cfw.Color = 37
generalText1.Cfw.Font = fntArial
generalText1.Cfw.Width = Annotations.LineWidth.Thin
generalText1.Italic = False
letteringPreferences1.SetGeneralText(generalText1)

tempWeldSymbol.SetLetteringPreferences(letteringPreferences1)

letteringPreferences1.Dispose()
lineAndArrowPreferences1.Dispose()

Next

'Change IDSymbol Settings

For Each tempIDSymbol As Annotations.IdSymbol In workPart.Annotations.IdSymbols

Dim lineAndArrowPreferences1 As Annotations.LineAndArrowPreferences
lineAndArrowPreferences1 = tempIDSymbol.GetLineAndArrowPreferences()

Dim letteringPreferences1 As Annotations.LetteringPreferences
letteringPreferences1 = tempIDSymbol.GetLetteringPreferences()

Dim generalText1 As Annotations.Lettering
generalText1.Size = 3.5
generalText1.CharacterSpaceFactor = 0.0
generalText1.AspectRatio = ratio
generalText1.LineSpaceFactor = 1.0
generalText1.Cfw.Color = 37
generalText1.Cfw.Font = fntArial
generalText1.Cfw.Width = Annotations.LineWidth.Thin
generalText1.Italic = False
letteringPreferences1.SetGeneralText(generalText1)

tempIDSymbol.SetLetteringPreferences(letteringPreferences1)

letteringPreferences1.Dispose()
lineAndArrowPreferences1.Dispose()

Next

'Change font in tables

'Change Dimension settings

Dim numBad As Integer = 0

For Each tempDim As Annotations.Dimension In workPart.Dimensions
Dim letteringPreferences1 As Annotations.LetteringPreferences
letteringPreferences1 = tempDim.GetLetteringPreferences()

'The next six lines changes the DistanceBetweenSymbolAndDimensionText

Dim dimensionPreferences1 As Annotations.DimensionPreferences = tempDim.GetDimensionPreferences()

Dim diameterRadiusPreferences1 As Annotations.DiameterRadiusPreferences = dimensionPreferences1.GetDiameterRadiusPreferences()

diameterRadiusPreferences1.DistanceBetweenSymbolAndDimensionText = 0.2

dimensionPreferences1.SetDiameterRadiusPreferences(diameterRadiusPreferences1)

diameterRadiusPreferences1.Dispose()

tempDim.SetDimensionPreferences(dimensionPreferences1)

''''''

Dim dimensionText1 As Annotations.Lettering = letteringPreferences1.GetDimensionText
Dim appendedText1 As Annotations.Lettering = letteringPreferences1.GetAppendedText
Dim toleranceText1 As Annotations.Lettering = letteringPreferences1.GetToleranceText

Dim mainText() As String
Dim dualText() As String
tempDim.GetDimensionText(mainText, dualText)

If dimensionText1.Size <> 0.01 Then
numBad += 1
dimensionText1.Cfw.Font = fntArial
dimensionText1.Size = 3.5
dimensionText1.AspectRatio = ratio
dimensionText1.Cfw.Width = Annotations.LineWidth.Thin
letteringPreferences1.SetDimensionText(dimensionText1)

End If

If appendedText1.Size <> 0.01 Then
numBad += 1
appendedText1.Cfw.Font = fntArial
appendedText1.Size = 3.5

appendedText1.Cfw.Width = Annotations.LineWidth.Thin
letteringPreferences1.SetAppendedText(appendedText1)
End If

If toleranceText1.Size <> 0.01 Then
numBad += 1
toleranceText1.Cfw.Font = fntArial
toleranceText1.Size = 3.5
toleranceText1.Cfw.Width = Annotations.LineWidth.Thin
letteringPreferences1.SetToleranceText(toleranceText1)
End If

tempDim.SetLetteringPreferences(letteringPreferences1)
letteringPreferences1.Dispose()

Next

'Change fonts in tabular notes

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

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

Dim myTabularNoteTags As New List(Of Tag)
If FindTabularNotes(myTabularNoteTags) = 0 Then
'no tabular notes to process
Return
End If

For Each tableNote As Tag In myTabularNoteTags

Dim numRows As Integer
theUfSession.Tabnot.AskNmRows(tableNote, numRows)

Dim numCols As Integer
theUfSession.Tabnot.AskNmColumns(tableNote, numCols)

Dim tableOrigin(2) As Double
Dim tableSectionTag As Tag
theUfSession.Tabnot.AskNthSection(tableNote, 0, tableSectionTag)

For i As Integer = 0 To numRows - 1
Dim rowTag As Tag
theUfSession.Tabnot.AskNthRow(tableNote, i, rowTag)

For j As Integer = 0 To numCols - 1
Dim colTag As Tag
theUfSession.Tabnot.AskNthColumn(tableNote, j, colTag)

Dim cellTag As Tag
theUfSession.Tabnot.AskCellAtRowCol(rowTag, colTag, cellTag)

'get the current cell preferences
Dim theCellPrefs As UFTabnot.CellPrefs
theUfSession.Tabnot.AskCellPrefs(cellTag, theCellPrefs)

'change the font preference setting
theCellPrefs.text_font = fntArial

'apply the new settings to the cell
theUfSession.Tabnot.SetCellPrefs(cellTag, theCellPrefs)

Next

Next

Next

lw.Close()

theSession.SetUndoMarkName(markId1, "Load Drafting Standard Dialog")

End Sub

Function FindTabularNotes(ByRef theTabNotes As List(Of Tag)) As Integer

Dim tmpTabNote As NXOpen.Tag = NXOpen.Tag.Null
Dim type As Integer
Dim subtype As Integer

Do
theUfSession.Obj.CycleObjsInPart(workPart.Tag, UFConstants.UF_tabular_note_type, tmpTabNote)
If tmpTabNote = NXOpen.Tag.Null Then
Continue Do
End If
If tmpTabNote <> NXOpen.Tag.Null Then
theUfSession.Obj.AskTypeAndSubtype(tmpTabNote, type, subtype)
If subtype = UFConstants.UF_tabular_note_subtype Then

theTabNotes.Add(tmpTabNote)

End If
End If
Loop Until tmpTabNote = NXOpen.Tag.Null

Return theTabNotes.Count

End Function

Public Function GetUnloadOption(ByVal dummy As String) As Integer

'Unloads the image when the NX session terminates
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination

'----Other unload options-------
'Unloads the image immediately after execution within NX
'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately

'Unloads the image explicitly, via an unload dialog
'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly
'-------------------------------

End Function

End Module

I have managed to stitch together another script that fixes the font for label on parents. So this script and the one I posted earlier works fine separately and gets the job done. But I don't know how to combine the two, as I don't understand how a function works:) Any tips on how to combine this script with the one I posted above?

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports System.Collections.Generic

' NX Font Update
' Journal created by Alto on 20-05-2015

Module NXJournal
Dim theUfSession As UFSession = UFSession.GetUFSession()
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work

Sub Main()

Dim fntArial As Integer = workPart.Fonts.AddFont("Arial", FontCollection.Type.Standard)

'Update Label Font for all the Labels not letter size factor

Dim NULL_TAG As NXOpen.Tag = NXOpen.Tag.Null
Dim obj As NXOpen.Tag = NULL_TAG

Do
obj = ask_next_drf_entity(obj)
If obj = NULL_TAG Then
GoTo end1
End If
' Check whether returned Tag is UF_draft_label_subtype
Dim type As Integer = Nothing
Dim subtype As Integer = Nothing
theUfSession.Obj.AskTypeAndSubtype(obj, type, subtype)
Dim nxobj As NXObject = Utilities.NXObjectManager.Get(obj)
If nxobj.GetType().ToString() <> "NXOpen.Annotations.Label" Then
Continue Do
ElseIf nxobj.GetType().ToString() <> "NXOpen.Annotations.Labelonparent" Then
Dim Label1 As Annotations.Label = nxobj
Dim letteringPreferences7 As Annotations.LetteringPreferences
letteringPreferences7 = Label1.GetLetteringPreferences()

Dim generalText5 As Annotations.Lettering
generalText5.Size = 3.5
generalText5.CharacterSpaceFactor = 0.0
generalText5.AspectRatio = 1.0
generalText5.LineSpaceFactor = 1.0
generalText5.Cfw.Color = 37
generalText5.Cfw.Font = fntArial
generalText5.Cfw.Width = Annotations.LineWidth.Thin
letteringPreferences7.SetGeneralText(generalText5)
Label1.SetLetteringPreferences(letteringPreferences7)
letteringPreferences7.Dispose()

Label1.RedisplayObject()
Continue Do

Else

Dim Label1 As Annotations.Label = nxobj
Dim letteringPreferences7 As Annotations.LetteringPreferences
letteringPreferences7 = Label1.GetLetteringPreferences()

Dim generalText5 As Annotations.Lettering
generalText5.Size = 3.5
generalText5.CharacterSpaceFactor = 0.0
generalText5.AspectRatio = 1.0
generalText5.LineSpaceFactor = 1.0
generalText5.Cfw.Color = 37
generalText5.Cfw.Font = fntArial
generalText5.Cfw.Width = Annotations.LineWidth.Thin
letteringPreferences7.SetGeneralText(generalText5)
Label1.SetLetteringPreferences(letteringPreferences7)
letteringPreferences7.Dispose()

Label1.RedisplayObject()

End If

Loop Until obj = NULL_TAG
End1:

End Sub

Public Function ask_next_drf_entity(ByRef obj As NXOpen.Tag) As NXOpen.Tag
Dim part As NXOpen.Tag = workPart.Tag
theUfSession.Obj.CycleObjsInPart(part, UFConstants.UF_drafting_entity_type, obj)
Return obj
End Function

Public Function GetUnloadOption(ByVal dummy As String) As Integer
'Unloads the image immediately after execution within NX
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
End Function

End Module

BR

Stian LA

Option Strict Off

Imports System
Imports System.Collections.Generic
Imports NXOpen
Imports NXOpen.UF
Module set_dim_text_to_arial

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

Sub Main()

Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "change dim text to Arial")

'Load Drafting Standards

Dim loadDraftingStandardBuilder1 As Preferences.LoadDraftingStandardBuilder
loadDraftingStandardBuilder1 = workPart.Preferences.DraftingPreference.CreateLoadDraftingStandardBuilder()

loadDraftingStandardBuilder1.WelcomeMode = False

loadDraftingStandardBuilder1.Level = Preferences.LoadDraftingStandardBuilder.LoadLevel.Site

loadDraftingStandardBuilder1.Name = "FMC_KBG"

Dim nXObject1 As NXObject
nXObject1 = loadDraftingStandardBuilder1.Commit()

loadDraftingStandardBuilder1.Destroy()

'Version up drafting objects

workPart.Drafting.VersionUpAllDraftingObjects()

'Declare Font type

Dim fntArial As Integer = workPart.Fonts.AddFont("Arial", FontCollection.Type.Standard)

'Declare Aspect Ratio

Dim ratio As String = 1

'Change GD&T Settings

For Each tempGdts As Annotations.Gdt In workPart.Gdts

Dim symbolPreferences1 As Annotations.SymbolPreferences
symbolPreferences1 = tempGdts.GetSymbolPreferences()

Dim lineAndArrowPreferences1 As Annotations.LineAndArrowPreferences
lineAndArrowPreferences1 = tempGdts.GetLineAndArrowPreferences()

Dim letteringPreferences1 As Annotations.LetteringPreferences
letteringPreferences1 = tempGdts.GetLetteringPreferences()

Dim generalText1 As Annotations.Lettering
generalText1.Size = 3.5
generalText1.CharacterSpaceFactor = 0.0
generalText1.AspectRatio = ratio
generalText1.LineSpaceFactor = 1.0
generalText1.Cfw.Color = 37
generalText1.Cfw.Font = fntArial
generalText1.Cfw.Width = Annotations.LineWidth.Thin
generalText1.Italic = False
letteringPreferences1.SetGeneralText(generalText1)

tempGdts.SetLetteringPreferences(letteringPreferences1)

letteringPreferences1.Dispose()
lineAndArrowPreferences1.Dispose()
symbolPreferences1.SetWeldSpaceFactor(2.0)

symbolPreferences1.SetWeldSymbolSizeFactor(1.0)

Dim weldSymbolCfw1 As Annotations.LineCfw = New Annotations.LineCfw(37, DisplayableObject.ObjectFont.Solid, Annotations.LineWidth.Thin)
symbolPreferences1.SetWeldSymbolCfw(weldSymbolCfw1)

Dim surfaceFinishCfw1 As Annotations.LineCfw = New Annotations.LineCfw(37, DisplayableObject.ObjectFont.Solid, Annotations.LineWidth.Thin)
symbolPreferences1.SetSurfaceFinishCfw(surfaceFinishCfw1)

symbolPreferences1.DraftingSurfaceFinishStandard = Annotations.SurfaceFinishStandard.Iso2002

symbolPreferences1.WeldSymbolStandard = Annotations.WeldStandard.Iso

tempGdts.SetSymbolPreferences(symbolPreferences1)

symbolPreferences1.Dispose()
tempGdts.LeaderOrientation = Annotations.LeaderOrientation.FromLeft

Dim nErrs1 As Integer

Next

'Change Note Settings

For Each tempNote As Annotations.Note In workPart.Notes

Dim lineAndArrowPreferences1 As Annotations.LineAndArrowPreferences
lineAndArrowPreferences1 = tempNote.GetLineAndArrowPreferences()

Dim letteringPreferences1 As Annotations.LetteringPreferences
letteringPreferences1 = tempNote.GetLetteringPreferences()

Dim generalText1 As Annotations.Lettering
generalText1.Size = 3.5
generalText1.CharacterSpaceFactor = 0.0
generalText1.AspectRatio = ratio
generalText1.LineSpaceFactor = 1.0
generalText1.Cfw.Color = 37
generalText1.Cfw.Font = fntArial
generalText1.Cfw.Width = Annotations.LineWidth.Thin
generalText1.Italic = False
letteringPreferences1.SetGeneralText(generalText1)

tempNote.SetLetteringPreferences(letteringPreferences1)

letteringPreferences1.Dispose()
lineAndArrowPreferences1.Dispose()

Next

'Change Label Settings

For Each tempLabel As Annotations.Label In workPart.Labels

Dim lineAndArrowPreferences1 As Annotations.LineAndArrowPreferences
lineAndArrowPreferences1 = tempLabel.GetLineAndArrowPreferences()

Dim letteringPreferences1 As Annotations.LetteringPreferences
letteringPreferences1 = tempLabel.GetLetteringPreferences()

Dim generalText1 As Annotations.Lettering
generalText1.Size = 3.5
generalText1.CharacterSpaceFactor = 0.0
generalText1.AspectRatio = ratio
generalText1.LineSpaceFactor = 1.0
generalText1.Cfw.Color = 37
generalText1.Cfw.Font = fntArial
generalText1.Cfw.Width = Annotations.LineWidth.Thin
generalText1.Italic = False
letteringPreferences1.SetGeneralText(generalText1)

tempLabel.SetLetteringPreferences(letteringPreferences1)

letteringPreferences1.Dispose()
lineAndArrowPreferences1.Dispose()

Next

'Change Weld Symbol Settings

For Each tempWeldSymbol As Annotations.Weld In workPart.Annotations.Welds

Dim lineAndArrowPreferences1 As Annotations.LineAndArrowPreferences
lineAndArrowPreferences1 = tempWeldSymbol.GetLineAndArrowPreferences()

Dim letteringPreferences1 As Annotations.LetteringPreferences
letteringPreferences1 = tempWeldSymbol.GetLetteringPreferences()

Dim generalText1 As Annotations.Lettering
generalText1.Size = 3.5
generalText1.CharacterSpaceFactor = 0.0
generalText1.AspectRatio = ratio
generalText1.LineSpaceFactor = 1.0
generalText1.Cfw.Color = 37
generalText1.Cfw.Font = fntArial
generalText1.Cfw.Width = Annotations.LineWidth.Thin
generalText1.Italic = False
letteringPreferences1.SetGeneralText(generalText1)

tempWeldSymbol.SetLetteringPreferences(letteringPreferences1)

letteringPreferences1.Dispose()
lineAndArrowPreferences1.Dispose()

Next

'Change IDSymbol Settings

For Each tempIDSymbol As Annotations.IdSymbol In workPart.Annotations.IdSymbols

Dim lineAndArrowPreferences1 As Annotations.LineAndArrowPreferences
lineAndArrowPreferences1 = tempIDSymbol.GetLineAndArrowPreferences()

Dim letteringPreferences1 As Annotations.LetteringPreferences
letteringPreferences1 = tempIDSymbol.GetLetteringPreferences()

Dim generalText1 As Annotations.Lettering
generalText1.Size = 3.5
generalText1.CharacterSpaceFactor = 0.0
generalText1.AspectRatio = ratio
generalText1.LineSpaceFactor = 1.0
generalText1.Cfw.Color = 37
generalText1.Cfw.Font = fntArial
generalText1.Cfw.Width = Annotations.LineWidth.Thin
generalText1.Italic = False
letteringPreferences1.SetGeneralText(generalText1)

tempIDSymbol.SetLetteringPreferences(letteringPreferences1)

letteringPreferences1.Dispose()
lineAndArrowPreferences1.Dispose()

Next

'Change font in tables

'Change Dimension settings

Dim numBad As Integer = 0

For Each tempDim As Annotations.Dimension In workPart.Dimensions
Dim letteringPreferences1 As Annotations.LetteringPreferences
letteringPreferences1 = tempDim.GetLetteringPreferences()

'The next six lines changes the DistanceBetweenSymbolAndDimensionText

Dim dimensionPreferences1 As Annotations.DimensionPreferences = tempDim.GetDimensionPreferences()

Dim diameterRadiusPreferences1 As Annotations.DiameterRadiusPreferences = dimensionPreferences1.GetDiameterRadiusPreferences()

diameterRadiusPreferences1.DistanceBetweenSymbolAndDimensionText = 0.2

dimensionPreferences1.SetDiameterRadiusPreferences(diameterRadiusPreferences1)

diameterRadiusPreferences1.Dispose()

tempDim.SetDimensionPreferences(dimensionPreferences1)

''''''

Dim dimensionText1 As Annotations.Lettering = letteringPreferences1.GetDimensionText
Dim appendedText1 As Annotations.Lettering = letteringPreferences1.GetAppendedText
Dim toleranceText1 As Annotations.Lettering = letteringPreferences1.GetToleranceText

Dim mainText() As String
Dim dualText() As String
tempDim.GetDimensionText(mainText, dualText)

If dimensionText1.Size <> 0.01 Then
numBad += 1
dimensionText1.Cfw.Font = fntArial
dimensionText1.Size = 3.5
dimensionText1.AspectRatio = ratio
dimensionText1.Cfw.Width = Annotations.LineWidth.Thin
letteringPreferences1.SetDimensionText(dimensionText1)

End If

If appendedText1.Size <> 0.01 Then
numBad += 1
appendedText1.Cfw.Font = fntArial
appendedText1.Size = 3.5

appendedText1.Cfw.Width = Annotations.LineWidth.Thin
letteringPreferences1.SetAppendedText(appendedText1)
End If

If toleranceText1.Size <> 0.01 Then
numBad += 1
toleranceText1.Cfw.Font = fntArial
toleranceText1.Size = 3.5
toleranceText1.Cfw.Width = Annotations.LineWidth.Thin
letteringPreferences1.SetToleranceText(toleranceText1)
End If

tempDim.SetLetteringPreferences(letteringPreferences1)
letteringPreferences1.Dispose()

Next

'Change fonts in tabular notes

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

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

Dim myTabularNoteTags As New List(Of Tag)
If FindTabularNotes(myTabularNoteTags) = 0 Then
'no tabular notes to process
Return
End If

For Each tableNote As Tag In myTabularNoteTags

Dim numRows As Integer
theUfSession.Tabnot.AskNmRows(tableNote, numRows)

Dim numCols As Integer
theUfSession.Tabnot.AskNmColumns(tableNote, numCols)

Dim tableOrigin(2) As Double
Dim tableSectionTag As Tag
theUfSession.Tabnot.AskNthSection(tableNote, 0, tableSectionTag)

For i As Integer = 0 To numRows - 1
Dim rowTag As Tag
theUfSession.Tabnot.AskNthRow(tableNote, i, rowTag)

For j As Integer = 0 To numCols - 1
Dim colTag As Tag
theUfSession.Tabnot.AskNthColumn(tableNote, j, colTag)

Dim cellTag As Tag
theUfSession.Tabnot.AskCellAtRowCol(rowTag, colTag, cellTag)

'get the current cell preferences
Dim theCellPrefs As UFTabnot.CellPrefs
theUfSession.Tabnot.AskCellPrefs(cellTag, theCellPrefs)

'change the font preference setting
theCellPrefs.text_font = fntArial

'apply the new settings to the cell
theUfSession.Tabnot.SetCellPrefs(cellTag, theCellPrefs)

Next

Next

Next

lw.Close()

'Update Label Font for all the Labels not letter size factor

Dim NULL_TAG As NXOpen.Tag = NXOpen.Tag.Null
Dim obj As NXOpen.Tag = NULL_TAG

Do
obj = ask_next_drf_entity(obj)
If obj = NULL_TAG Then
GoTo end1
End If
' Check whether returned Tag is UF_draft_label_subtype
Dim type As Integer = Nothing
Dim subtype As Integer = Nothing
theUfSession.Obj.AskTypeAndSubtype(obj, type, subtype)
Dim nxobj As NXObject = Utilities.NXObjectManager.Get(obj)
If nxobj.GetType().ToString() <> "NXOpen.Annotations.Label" Then
Continue Do
ElseIf nxobj.GetType().ToString() <> "NXOpen.Annotations.Labelonparent" Then
Dim Label1 As Annotations.Label = nxobj
Dim letteringPreferences7 As Annotations.LetteringPreferences
letteringPreferences7 = Label1.GetLetteringPreferences()

Dim generalText5 As Annotations.Lettering
generalText5.Size = 3.5
generalText5.CharacterSpaceFactor = 0.0
generalText5.AspectRatio = 1.0
generalText5.LineSpaceFactor = 1.0
generalText5.Cfw.Color = 37
generalText5.Cfw.Font = fntArial
generalText5.Cfw.Width = Annotations.LineWidth.Thin
letteringPreferences7.SetGeneralText(generalText5)
Label1.SetLetteringPreferences(letteringPreferences7)
letteringPreferences7.Dispose()

Label1.RedisplayObject()
Continue Do

Else

Dim Label1 As Annotations.Label = nxobj
Dim letteringPreferences7 As Annotations.LetteringPreferences
letteringPreferences7 = Label1.GetLetteringPreferences()

Dim generalText5 As Annotations.Lettering
generalText5.Size = 3.5
generalText5.CharacterSpaceFactor = 0.0
generalText5.AspectRatio = 1.0
generalText5.LineSpaceFactor = 1.0
generalText5.Cfw.Color = 37
generalText5.Cfw.Font = fntArial
generalText5.Cfw.Width = Annotations.LineWidth.Thin
letteringPreferences7.SetGeneralText(generalText5)
Label1.SetLetteringPreferences(letteringPreferences7)
letteringPreferences7.Dispose()

Label1.RedisplayObject()

End If

Loop Until obj = NULL_TAG
End1:

End Sub

Public Function ask_next_drf_entity(ByRef obj As NXOpen.Tag) As NXOpen.Tag
Dim part As NXOpen.Tag = workPart.Tag
theUfSession.Obj.CycleObjsInPart(part, UFConstants.UF_drafting_entity_type, obj)
Return obj
End Function

Function FindTabularNotes(ByRef theTabNotes As List(Of Tag)) As Integer

Dim tmpTabNote As NXOpen.Tag = NXOpen.Tag.Null
Dim type As Integer
Dim subtype As Integer

Do
theUfSession.Obj.CycleObjsInPart(workPart.Tag, UFConstants.UF_tabular_note_type, tmpTabNote)
If tmpTabNote = NXOpen.Tag.Null Then
Continue Do
End If
If tmpTabNote <> NXOpen.Tag.Null Then
theUfSession.Obj.AskTypeAndSubtype(tmpTabNote, type, subtype)
If subtype = UFConstants.UF_tabular_note_subtype Then

theTabNotes.Add(tmpTabNote)

End If
End If
Loop Until tmpTabNote = NXOpen.Tag.Null

Return theTabNotes.Count

End Function

Public Function GetUnloadOption(ByVal dummy As String) As Integer

'Unloads the image when the NX session terminates
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination

'----Other unload options-------
'Unloads the image immediately after execution within NX
'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately

'Unloads the image explicitly, via an unload dialog
'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly
'-------------------------------

End Function

End Module

BR

Stian LA

The code below illustrates one method for changing the font on the detail views "label on parent".

Edit: Looks like I posted before I checked for updates. It appears that we came to very similar solutions. Glad that you got it working!

Option Strict Off
Imports System
Imports System.Collections.Generic
Imports NXOpen
Imports NXOpen.UF

Module Module1

Dim theSession As Session = Session.GetSession()
Dim theUfSession As UFSession = UFSession.GetUFSession

Dim workPart As Part = theSession.Parts.Work

Sub Main()

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

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

Const undoMarkName As String = "change font: detail view label on parent"
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, undoMarkName)

Dim parentLabels As New List(Of Annotations.Label)
FindLabelsOnParent(parentLabels)

For Each temp As Annotations.Label In parentLabels

Dim editSettingsBuilder1 As Annotations.EditSettingsBuilder
editSettingsBuilder1 = workPart.SettingsManager.CreateAnnotationEditSettingsBuilder({temp})

Dim editsettingsbuilders1(0) As Drafting.BaseEditSettingsBuilder
editsettingsbuilders1(0) = editSettingsBuilder1
workPart.SettingsManager.ProcessForMutipleObjectsSettings(editsettingsbuilders1)

Dim fontIndex1 As Integer
fontIndex1 = workPart.Fonts.AddFont("Arial", FontCollection.Type.Standard)

editSettingsBuilder1.AnnotationStyle.LetteringStyle.GeneralTextFont = fontIndex1

Dim nXObject1 As NXObject
nXObject1 = editSettingsBuilder1.Commit()

editSettingsBuilder1.Destroy()

Next

lw.Close()

End Sub

Function FindLabelsOnParent(ByRef theLabels As List(Of Annotations.Label)) As Integer

Dim tmpLabel As NXOpen.Tag = NXOpen.Tag.Null
Dim type As Integer
Dim subtype As Integer

Do
theUfSession.Obj.CycleObjsInPart(workPart.Tag, UFConstants.UF_drafting_entity_type, tmpLabel)
If tmpLabel = NXOpen.Tag.Null Then
Continue Do
End If
If tmpLabel <> NXOpen.Tag.Null Then
theUfSession.Obj.AskTypeAndSubtype(tmpLabel, type, subtype)
If subtype = UFConstants.UF_draft_label_on_parent_subtype Then
Try
Dim parentLabel As Annotations.Label
parentLabel = Utilities.NXObjectManager.Get(tmpLabel)
theLabels.Add(parentLabel)
Catch ex As NXException
'skip it
End Try

End If
End If
Loop Until tmpLabel = NXOpen.Tag.Null

Return theLabels.Count

End Function

Public Function GetUnloadOption(ByVal dummy As String) As Integer

'Unloads the image immediately after execution within NX
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately

End Function

End Module

Yes, looks very similar. Was able to solve it myself, but thanks a lot for your effort!

This was my first post, maybe you can teach me how to post the code in that nice box with the red and blue markings? :)

BR

Stian LA

To get the code markup, all you have to do is surround your code with special tags. The opening tag is <vbnet> and the closing tag is </vbnet>. So, it would look something like this in the entry box (before the text is processed):

<vbnet
Option Strict Off
Imports System
Imports System.Collections.Generic
Imports NXOpen
Imports NXOpen.UF
.
.
.
</vbnet>

Great. Thanks a lot!

Option Strict Off
Imports System
Imports System.Collections.Generic
Imports NXOpen
Imports NXOpen.UF

BR

Stian LA