Submitted by paehv on Thu, 05/01/2014 - 04:36
Forums:
Trying to create a journal that will change all (old UG) lettering font to Arial on a drawing sheet.
So far I can set everything except the fonts that are used in drafting tables.
I can't even figure it out after recording a journal.
Any ideas???
re: change font of tabular note
'NXJournaling.com
'May 1, 2014
'find all tabular notes in the work part
'change the font to Arial
'
'http://nxjournaling.com/?q=content/change-font-drafting-table
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.Work) Then
'active part required
Return
End If
Dim lw As ListingWindow = theSession.ListingWindow
lw.Open()
Const undoMarkName As String = "NXJ change tabular note font"
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, undoMarkName)
'find/assign font number
Dim fntArial As Integer = workPart.Fonts.AddFont("Arial", FontCollection.Type.Standard)
'lw.WriteLine("Arial font number: " & fntArial.ToString)
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()
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
Change font of tabular note
Thanks a lot. I would never have figured this out.
I finally got a journal that replaces ALL fonts on a drawing. We have 10000+ drawings from UG V10 to NX 9.0
Now I can get rid of the terrible block_font that show up in all the older drawings.
Patrick Delisse
DutchAero
journal for replacing the fonts in all dimensions, ...
Hello,
do you have a journal for replacing the fonts in all dimensions, notes, labels ... used in an existing drawing,
perhaps combined with tabular notes?
Thanks a lot!,
Best regards, Martin
journal to replace fonts on drawing
Hello Patrick,
please post the journal you used for replacing the fonts in dimensions, notes, labels ...
Thanks a lot!,
Best regards, Martin