Need program that will identify a font number for each computer automatically.

I created a text macro. It automates the text and the font (Arial Narrow). The macro works great on my computer but when used on another computer the font changes. The font changes because the Macro see's my font choice as a number on my system, it doesn't see it as Arial Narrow, it sees it as number 65. This number can change from computer to computer. So I'm looking for something I can add to my Macro that will scan someones computer to find out what number Arial Narrow is and then automatically apply that number.

This looks like a NX number association. As far as I know, Windows doesn’t number its fonts. This must be something specific to NX. There may be a function call for this. Does anyone know of a function like this?

Thank you for your time,

Lisa

NX parts use a "font table" which is a sort of database to keep track of the fonts used in the part. Each font is given an integer ID value when the font is used in the part. The font index number for a particular font can/will vary from part to part.

The .AddFont method returns the font index of the added font. If the font already exists in the part, it is not added again, but the existing font index is returned. Alternately, you can iterate through the part's font collection to see if a particular font is used.

The example code below writes information about each font used in the work part (font index, name, and type) then it adds a common font (one that is probably already in the part file) and reports its font index number.

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF

Module Module1

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

Dim theUI As UI = UI.GetUI()
Dim lw As ListingWindow = theSession.ListingWindow

Sub Main()

Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "NXJ")

lw.Open()

For i As Integer = 1 To theSession.Parts.Work.Fonts.GetLength
lw.WriteLine("font index: " & i.ToString)
lw.WriteLine(theSession.Parts.Work.Fonts.GetFontName(i))
lw.WriteLine(theSession.Parts.Work.Fonts.GetFontType(i).ToString)
lw.WriteLine("")
Next

Dim fontIndex As Integer
fontIndex = theSession.Parts.Work.Fonts.AddFont("Arial Unicode MS", FontCollection.Type.Standard)
lw.WriteLine("Arial Unicode MS font index: " & fontIndex.ToString)

lw.Close()

End Sub

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

Thanks for the helpful information. Can you tell me how I would incorporate the above code with a simple text macro, like below, keeping in mind I want to keep the font to Arial Narrow, Western, Regular.

I appreciate your time. I'm at the start of trying to get more into the details of programming with NX. Thank you for your input!
NX 8.5.3.3
Macro File: C:\Users\martili\Documents\MACRO\Part Marking\TEXT_Example.macro
Macro Version 7.50
Macro List Language and Codeset: english 17
Created by martili on Thu Sep 08 07:58:33 2016
Part Name Display Style: $FILENAME
Selection Parameters 1 2 0.229167 1
Display Parameters 1.000000 15.697917 8.385417 -1.000000 -0.534174 1.000000 0.534174
*****************
RESET
CURSOR_EVENT 1001 3,1,100,0 ! single_pt, mb1/0+0, , nn
CPOS -5.45231474873746,5.70438987059165,-6.38959887006013
MENU, 0, UG_CURVE_TEXT UG_GATEWAY_MAIN_MENUBAR ## !
ASK_ITEM 5046272 (1 OPTT 0) = 10 0 ! YC-ZC Plane
ASK_ITEM 5046272 (1 OPTT 0) = 0 1 ! Inferred
ASK_ITEM 5046272 (1 OPTT 0) = 0 1 ! Inferred
ASK_ITEM 5046272 (1 OPTT 0) = 0 1 ! Inferred
ASK_ITEM 5046272 (1 OPTT 0) = 0 1 ! Inferred
ASK_ITEM 5046272 (1 OPTT 0) = 0 0 ! Inferred
ASK_ITEM 7274496 (1 OPTT 0) = 10 0 ! -ZC-axis
ASK_ITEM 7274496 (1 OPTT 0) = 0 1 ! Inferred Vector
ASK_ITEM 7274496 (1 OPTT 0) = 0 1 ! Inferred Vector
ASK_ITEM 7274496 (1 OPTT 0) = 0 0 ! Inferred Vector
ASK_ITEM 9633792 (1 BOOL 0) = 1 ! Reference Text
ASK_ITEM 9633792 (1 BOOL 0) = 0 ! Reference Text
ASK_ITEM 10420224 (1 BOOL 0) = 1 !
ASK_ITEM 10747904 (1 BOOL 0) = 1 !
ASK_ITEM 10747904 (1 BOOL 0) = 0 !
ASK_ITEM 12648448 (1 OPTT 0) = 10 0 ! Fixed
ASK_ITEM 12648448 (1 OPTT 0) = 10 1 ! Fixed
ASK_ITEM 12648448 (1 OPTT 0) = 10 1 ! Fixed
ASK_ITEM 12648448 (1 OPTT 0) = 10 0 ! Fixed
ASK_ITEM 24379392 (1 BOOL 0) = 1 ! Associative
ASK_ITEM 24576000 (1 BOOL 0) = 1 ! Join Curves
ASK_ITEM 24772608 (1 BOOL 0) = 1 ! Project Curves
ASK_ITEM 16121856 (1 REAL 0) = 114.3562493080900000 ! W Scale
ASK_ITEM 16121856 (1 REAL 0) = 114.3562493080900000 ! W Scale
DIALOG_BEGIN "Text" 0 ! DA2
BEG_ITEM 262144 (1 OPTM 0) = 0 ! Planar
BEG_ITEM 262146 (1 TOOL 0) = 0 ! Planar
BEG_ITEM 1179648 (1 BOOL 0) = 0 ! Curve
BEG_ITEM 2686976 (1 BOOL 0) = 0 ! Face
BEG_ITEM 3670016 (1 OPTM 0) = 0 ! Curves on Faces
BEG_ITEM 3866624 (1 BOOL 0) = 0 ! Curve
BEG_ITEM 5046272 (1 OPTT 0) = 0 0 ! Inferred
BEG_ITEM 5832704 (1 OPTM 0) = 0 ! Inferred
BEG_ITEM 5832706 (1 TOOL 0) = 0 ! Inferred
BEG_ITEM 7012352 (1 OPTM 0) = 0 ! Natural
BEG_ITEM 7274496 (1 OPTT 0) = 0 0 ! Inferred Vector
BEG_ITEM 8257536 (1 OPTM 0) = 0 ! Inferred Vector
BEG_ITEM 8257538 (1 TOOL 0) = 0 ! Inferred Vector
BEG_ITEM 9175040 (1 STRN 0) = "34" !
BEG_ITEM 9633792 (1 BOOL 0) = 0 ! Reference Text
BEG_ITEM 9830400 (1 OPTM 0) = 65 ! Arial Narrow
BEG_ITEM 10027008 (1 OPTM 0) = 1 ! Western
BEG_ITEM 10223616 (1 OPTM 0) = 0 ! Regular
BEG_ITEM 10420224 (1 BOOL 0) = 1 !
BEG_ITEM 10747904 (1 BOOL 0) = 0 !
BEG_ITEM 11534336 (1 OPTM 0) = 8 ! Bottom Right
BEG_ITEM 11927552 (1 BOOL 0) = 0 !
BEG_ITEM 12648448 (1 OPTT 0) = 10 0 ! Fixed
BEG_ITEM 13238272 (1 OPTM 0) = 10 ! Fixed
BEG_ITEM 13238274 (1 TOOL 0) = 5 ! Fixed
BEG_ITEM 13828096 (1 OPTT 0) = 0 0 ! Inferred
BEG_ITEM 14942210 (1 OPTM 0) = 2 ! in
BEG_ITEM 14942211 (1 STRN 0) = "0.739497894604745" ! Length
BEG_ITEM 15663106 (1 OPTM 0) = 2 ! in
BEG_ITEM 15663107 (1 STRN 0) = "0.12" ! Height
BEG_ITEM 16121856 (1 REAL 0) = 114.3562493080900000 ! W Scale
BEG_ITEM 16580610 (1 OPTM 0) = 1 ! deg
BEG_ITEM 16580611 (1 STRN 0) = "0" ! Shear
BEG_ITEM 17367040 (1 OPTM 0) = 0 ! Center
BEG_ITEM 17629184 (1 OPTM 0) = 2 ! % Parameter
BEG_ITEM 17629186 (1 TOOL 0) = 2 ! % Parameter
BEG_ITEM 18350082 (1 OPTM 0) = 0 ! ???
BEG_ITEM 18350083 (1 STRN 0) = "65" ! % Parameter
BEG_ITEM 19267586 (1 OPTM 0) = 2 ! in
BEG_ITEM 19267587 (1 STRN 0) = "0.164950842901347" ! Offset
BEG_ITEM 19988482 (1 OPTM 0) = 2 ! in
BEG_ITEM 19988483 (1 STRN 0) = "0.88893068486898" ! Length
BEG_ITEM 20709378 (1 OPTM 0) = 2 ! in
BEG_ITEM 20709379 (1 STRN 0) = "0.12" ! Height
BEG_ITEM 21168128 (1 REAL 0) = 195.4899596471000000 ! W Scale
BEG_ITEM 21954560 (1 OPTM 0) = 4 ! Show Shortcuts
BEG_ITEM 21954562 (1 TOOL 0) = 2 ! % Parameter
BEG_ITEM 22609920 (1 OPTM 0) = 4 ! Show Shortcuts
BEG_ITEM 22609922 (1 TOOL 0) = 2 ! % Parameter
BEG_ITEM 23265280 (1 OPTM 0) = 4 ! Show Shortcuts
BEG_ITEM 23265282 (1 TOOL 0) = 2 ! % Parameter
BEG_ITEM 24379392 (1 BOOL 0) = 1 ! Associative
BEG_ITEM 24576000 (1 BOOL 0) = 1 ! Join Curves
BEG_ITEM 24772608 (1 BOOL 0) = 1 ! Project Curves
BEG_ITEM 25362434 (1 BOOL 0) = 1 ! Preview
ASK_ITEM 11927552 (1 BOOL 0) = 0 !
ASK_ITEM 11927552 (1 BOOL 0) = 1 !
EVENT VALUE_CHANGED 0 0, 9175040, 0, 0, 0!
ASK_ITEM 9175040 (1 STRN 0) = "T" !
EVENT VALUE_CHANGED 0 0, 14942211, 0, 0, 0! Length
ASK_ITEM 14942211 (1 STRN 0) = "0.739497894604745" ! Length
EVENT VALUE_CHANGED 0 0, 15663107, 0, 0, 0! Height
ASK_ITEM 15663107 (1 STRN 0) = "0.12" ! Height
ASK_ITEM 16121856 (1 REAL 0) = 114.3562493080900000 ! W Scale
ASK_ITEM 16121856 (1 REAL 0) = 114.3562493080900000 ! W Scale
EVENT VALUE_CHANGED 0 0, 9175040, 0, 0, 0!
ASK_ITEM 9175040 (1 STRN 0) = "Th" !
EVENT VALUE_CHANGED 0 0, 14942211, 0, 0, 0! Length
ASK_ITEM 14942211 (1 STRN 0) = "0.739497894604745" ! Length
EVENT VALUE_CHANGED 0 0, 15663107, 0, 0, 0! Height
ASK_ITEM 15663107 (1 STRN 0) = "0.12" ! Height
ASK_ITEM 16121856 (1 REAL 0) = 114.3562493080900000 ! W Scale
ASK_ITEM 16121856 (1 REAL 0) = 114.3562493080900000 ! W Scale
EVENT VALUE_CHANGED 0 0, 9175040, 0, 0, 0!
ASK_ITEM 9175040 (1 STRN 0) = "Thi" !
EVENT VALUE_CHANGED 0 0, 14942211, 0, 0, 0! Length
ASK_ITEM 14942211 (1 STRN 0) = "0.739497894604745" ! Length
EVENT VALUE_CHANGED 0 0, 15663107, 0, 0, 0! Height
ASK_ITEM 15663107 (1 STRN 0) = "0.12" ! Height
ASK_ITEM 16121856 (1 REAL 0) = 114.3562493080900000 ! W Scale
ASK_ITEM 16121856 (1 REAL 0) = 114.3562493080900000 ! W Scale
EVENT VALUE_CHANGED 0 0, 9175040, 0, 0, 0!
ASK_ITEM 9175040 (1 STRN 0) = "This" !
EVENT VALUE_CHANGED 0 0, 14942211, 0, 0, 0! Length
ASK_ITEM 14942211 (1 STRN 0) = "0.739497894604745" ! Length
EVENT VALUE_CHANGED 0 0, 15663107, 0, 0, 0! Height
ASK_ITEM 15663107 (1 STRN 0) = "0.12" ! Height
ASK_ITEM 16121856 (1 REAL 0) = 114.3562493080900000 ! W Scale
ASK_ITEM 16121856 (1 REAL 0) = 114.3562493080900000 ! W Scale
EVENT VALUE_CHANGED 0 0, 9175040, 0, 0, 0!
ASK_ITEM 9175040 (1 STRN 0) = "This " !
EVENT VALUE_CHANGED 0 0, 14942211, 0, 0, 0! Length
ASK_ITEM 14942211 (1 STRN 0) = "0.739497894604745" ! Length
EVENT VALUE_CHANGED 0 0, 15663107, 0, 0, 0! Height
ASK_ITEM 15663107 (1 STRN 0) = "0.12" ! Height
ASK_ITEM 16121856 (1 REAL 0) = 114.3562493080900000 ! W Scale
ASK_ITEM 16121856 (1 REAL 0) = 114.3562493080900000 ! W Scale
EVENT VALUE_CHANGED 0 0, 9175040, 0, 0, 0!
ASK_ITEM 9175040 (1 STRN 0) = "This i" !
EVENT VALUE_CHANGED 0 0, 14942211, 0, 0, 0! Length
ASK_ITEM 14942211 (1 STRN 0) = "0.739497894604745" ! Length
EVENT VALUE_CHANGED 0 0, 15663107, 0, 0, 0! Height
ASK_ITEM 15663107 (1 STRN 0) = "0.12" ! Height
ASK_ITEM 16121856 (1 REAL 0) = 114.3562493080900000 ! W Scale
ASK_ITEM 16121856 (1 REAL 0) = 114.3562493080900000 ! W Scale
EVENT VALUE_CHANGED 0 0, 9175040, 0, 0, 0!
ASK_ITEM 9175040 (1 STRN 0) = "This is" !
EVENT VALUE_CHANGED 0 0, 14942211, 0, 0, 0! Length
ASK_ITEM 14942211 (1 STRN 0) = "0.739497894604745" ! Length
EVENT VALUE_CHANGED 0 0, 15663107, 0, 0, 0! Height
ASK_ITEM 15663107 (1 STRN 0) = "0.12" ! Height
ASK_ITEM 16121856 (1 REAL 0) = 114.3562493080900000 ! W Scale
ASK_ITEM 16121856 (1 REAL 0) = 114.3562493080900000 ! W Scale
EVENT VALUE_CHANGED 0 0, 9175040, 0, 0, 0!
ASK_ITEM 9175040 (1 STRN 0) = "This is " !
EVENT VALUE_CHANGED 0 0, 14942211, 0, 0, 0! Length
ASK_ITEM 14942211 (1 STRN 0) = "0.739497894604745" ! Length
EVENT VALUE_CHANGED 0 0, 15663107, 0, 0, 0! Height
ASK_ITEM 15663107 (1 STRN 0) = "0.12" ! Height
ASK_ITEM 16121856 (1 REAL 0) = 114.3562493080900000 ! W Scale
ASK_ITEM 16121856 (1 REAL 0) = 114.3562493080900000 ! W Scale
EVENT VALUE_CHANGED 0 0, 9175040, 0, 0, 0!
ASK_ITEM 9175040 (1 STRN 0) = "This is a" !
EVENT VALUE_CHANGED 0 0, 14942211, 0, 0, 0! Length
ASK_ITEM 14942211 (1 STRN 0) = "0.739497894604745" ! Length
EVENT VALUE_CHANGED 0 0, 15663107, 0, 0, 0! Height
ASK_ITEM 15663107 (1 STRN 0) = "0.12" ! Height
ASK_ITEM 16121856 (1 REAL 0) = 114.3562493080900000 ! W Scale
ASK_ITEM 16121856 (1 REAL 0) = 114.3562493080900000 ! W Scale
EVENT VALUE_CHANGED 0 0, 9175040, 0, 0, 0!
ASK_ITEM 9175040 (1 STRN 0) = "This is a " !
EVENT VALUE_CHANGED 0 0, 14942211, 0, 0, 0! Length
ASK_ITEM 14942211 (1 STRN 0) = "0.739497894604745" ! Length
EVENT VALUE_CHANGED 0 0, 15663107, 0, 0, 0! Height
ASK_ITEM 15663107 (1 STRN 0) = "0.12" ! Height
ASK_ITEM 16121856 (1 REAL 0) = 114.3562493080900000 ! W Scale
ASK_ITEM 16121856 (1 REAL 0) = 114.3562493080900000 ! W Scale
EVENT VALUE_CHANGED 0 0, 9175040, 0, 0, 0!
ASK_ITEM 9175040 (1 STRN 0) = "This is a t" !
EVENT VALUE_CHANGED 0 0, 14942211, 0, 0, 0! Length
ASK_ITEM 14942211 (1 STRN 0) = "0.739497894604745" ! Length
EVENT VALUE_CHANGED 0 0, 15663107, 0, 0, 0! Height
ASK_ITEM 15663107 (1 STRN 0) = "0.12" ! Height
ASK_ITEM 16121856 (1 REAL 0) = 114.3562493080900000 ! W Scale
ASK_ITEM 16121856 (1 REAL 0) = 114.3562493080900000 ! W Scale
EVENT VALUE_CHANGED 0 0, 9175040, 0, 0, 0!
ASK_ITEM 9175040 (1 STRN 0) = "This is a te" !
EVENT VALUE_CHANGED 0 0, 14942211, 0, 0, 0! Length
ASK_ITEM 14942211 (1 STRN 0) = "0.739497894604745" ! Length
EVENT VALUE_CHANGED 0 0, 15663107, 0, 0, 0! Height
ASK_ITEM 15663107 (1 STRN 0) = "0.12" ! Height
ASK_ITEM 16121856 (1 REAL 0) = 114.3562493080900000 ! W Scale
ASK_ITEM 16121856 (1 REAL 0) = 114.3562493080900000 ! W Scale
EVENT VALUE_CHANGED 0 0, 9175040, 0, 0, 0!
ASK_ITEM 9175040 (1 STRN 0) = "This is a tes" !
EVENT VALUE_CHANGED 0 0, 14942211, 0, 0, 0! Length
ASK_ITEM 14942211 (1 STRN 0) = "0.739497894604745" ! Length
EVENT VALUE_CHANGED 0 0, 15663107, 0, 0, 0! Height
ASK_ITEM 15663107 (1 STRN 0) = "0.12" ! Height
ASK_ITEM 16121856 (1 REAL 0) = 114.3562493080900000 ! W Scale
ASK_ITEM 16121856 (1 REAL 0) = 114.3562493080900000 ! W Scale
EVENT VALUE_CHANGED 0 0, 9175040, 0, 0, 0!
ASK_ITEM 9175040 (1 STRN 0) = "This is a test" !
EVENT VALUE_CHANGED 0 0, 14942211, 0, 0, 0! Length
ASK_ITEM 14942211 (1 STRN 0) = "0.739497894604745" ! Length
EVENT VALUE_CHANGED 0 0, 15663107, 0, 0, 0! Height
ASK_ITEM 15663107 (1 STRN 0) = "0.12" ! Height
ASK_ITEM 16121856 (1 REAL 0) = 114.3562493080900000 ! W Scale
ASK_ITEM 16121856 (1 REAL 0) = 114.3562493080900000 ! W Scale
EVENT FOCUS_IN 0 0, 9830400, 65, 0, 0! Arial Narrow
ASK_ITEM 9830400 (1 OPTM 0) = 65 ! Arial Narrow
ASK_ITEM 9175040 (1 STRN 0) = "This is a test" !
EVENT VALUE_CHANGED 0 0, 14942211, 0, 0, 0! Length
ASK_ITEM 14942211 (1 STRN 0) = "0.739497894604745" ! Length
EVENT VALUE_CHANGED 0 0, 15663107, 0, 0, 0! Height
ASK_ITEM 15663107 (1 STRN 0) = "0.12" ! Height
ASK_ITEM 16121856 (1 REAL 0) = 114.3562493080900000 ! W Scale
ASK_ITEM 16121856 (1 REAL 0) = 114.3562493080900000 ! W Scale
EVENT ACTIVATE 0 0, 9830400, 65, 0, 0! Arial Narrow
ASK_ITEM 9830400 (1 OPTM 0) = 65 ! Arial Narrow
EVENT FOCUS_IN 0 0, 10027008, 1, 0, 0! Western
ASK_ITEM 10027008 (1 OPTM 0) = 1 ! Western
EVENT ACTIVATE 0 0, 10027008, 1, 0, 0! Western
ASK_ITEM 10027008 (1 OPTM 0) = 1 ! Western
EVENT FOCUS_IN 0 0, 10223616, 0, 0, 0! Regular
ASK_ITEM 10223616 (1 OPTM 0) = 0 ! Regular
EVENT ACTIVATE 0 0, 10223616, 0, 0, 0! Regular
ASK_ITEM 10223616 (1 OPTM 0) = 0 ! Regular
FOCUS CHANGE IN 1

My apologies, you asked about a macro and I responded with journal code. I usually write code for NX through the API rather than with the macro system. I'm not sure how you would determine the proper font with a macro. However, depending on what you need to accomplish, a journal may be a better choice.

It appears that you want to create a text curve feature on the model. This can be accomplished with a journal. If you provide more details on what you want to automate, I can help provide some code.

Thank you for that explanation. I actually am creating a very simple program. That will automatically do the following actions:
From Modeling
Insert --> Curve
Enter Text (this is a standard text we use, which drives the need for this, but to keep it simple, lets just use, "TEST"
Make sure the font is Arial Narrow, Western, Regular.

Result: user selects button, text and font are automatically assigned.

I don't mind using journaling and I'm just starting to get into SNAP so I'm open for suggestions. This font thing has come up with other things so I'm hoping you can help me. I appreciate your time and consideration.

Below is a journal that will create a text feature at coordinate (2,1,0). The code creates the curves in space, for a real application you would probably want to tie the curve feature to a datum plane or planar face.

Option Strict Off
Imports System
Imports NXOpen

Module NXJournal
Sub Main (ByVal args() As String)

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

Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Text")

Dim nullFeatures_Text As Features.Text = Nothing

Dim textBuilder1 As Features.TextBuilder
textBuilder1 = workPart.Features.CreateTextBuilder(nullFeatures_Text)

Dim origin1 As Point3d = New Point3d(0.0, 0.0, 0.0)
Dim normal1 As Vector3d = New Vector3d(0.0, 0.0, 1.0)
Dim plane1 As Plane
plane1 = workPart.Planes.CreatePlane(origin1, normal1, SmartObject.UpdateOption.WithinModeling)

textBuilder1.SectionPlane = plane1

textBuilder1.PlanarFrame.AnchorLocation = GeometricUtilities.RectangularFrameBuilder.AnchorLocationType.BottomCenter

textBuilder1.PlanarFrame.Height.RightHandSide = "0.12"

textBuilder1.PlanarFrame.WScale = 100.0

textBuilder1.SelectFont("Arial Narrow", Features.TextBuilder.ScriptOptions.Western)

textBuilder1.TextString = "TEST"

Dim coordinates2 As Point3d = New Point3d(2.0, 1.0, 0.0)
Dim point2 As Point
point2 = workPart.Points.CreatePoint(coordinates2)

textBuilder1.PlanarFrame.AnchorLocator.SetValue(point2, workPart.ModelingViews.WorkView, point2.Coordinates)

Dim nXObject1 As NXObject
nXObject1 = textBuilder1.Commit()

textBuilder1.Destroy()

plane1.DestroyPlane()

End Sub
End Module

This is good, I tried it out. I'm sorry but can you tell me where exactly in the above code is it finding the index number so that the same font shows up no matter what workstation/laptop you are on?

Maybe a better question is how do I add the font function that you first displayed to this journal.
' NX 8.5.3.3
' Journal created by martili on Thu Sep 08 14:46:17 2016 Pacific Daylight Time
'
Option Strict Off
Imports System
Imports NXOpen

Module NXJournal
Sub Main (ByVal args() As String)

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

Dim displayPart As Part = theSession.Parts.Display

' ----------------------------------------------
' Menu: Insert->Curve->Text...
' ----------------------------------------------
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Start")

Dim nullFeatures_Text As Features.Text = Nothing

If Not workPart.Preferences.Modeling.GetHistoryMode Then
Throw(New Exception("Create or edit of a Feature was recorded in History Mode but playback is in History-Free Mode."))
End If

Dim textBuilder1 As Features.TextBuilder
textBuilder1 = workPart.Features.CreateTextBuilder(nullFeatures_Text)

Dim origin1 As Point3d = New Point3d(0.0, 0.0, 0.0)
Dim normal1 As Vector3d = New Vector3d(0.0, 0.0, 1.0)
Dim plane1 As Plane
plane1 = workPart.Planes.CreatePlane(origin1, normal1, SmartObject.UpdateOption.WithinModeling)

textBuilder1.SectionPlane = plane1

Dim unit1 As Unit
unit1 = textBuilder1.PlanarFrame.Length.Units

Dim expression1 As Expression
expression1 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)

Dim expression2 As Expression
expression2 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)

Dim coordinates1 As Point3d = New Point3d(0.0, 0.0, 0.0)
Dim point1 As Point
point1 = workPart.Points.CreatePoint(coordinates1)

textBuilder1.FrameOnPath.AnchorPosition.Expression.RightHandSide = "50"

textBuilder1.Script = Features.TextBuilder.ScriptOptions.Western

textBuilder1.PlanarFrame.AnchorLocation = GeometricUtilities.RectangularFrameBuilder.AnchorLocationType.BottomRight

textBuilder1.PlanarFrame.Length.RightHandSide = "0.160748201253033"

textBuilder1.PlanarFrame.Height.RightHandSide = "0.12"

textBuilder1.PlanarFrame.WScale = 114.356249308092

textBuilder1.PlanarFrame.Shear.RightHandSide = "0"

textBuilder1.FrameOnPath.AnchorPosition.Expression.RightHandSide = "65"

textBuilder1.FrameOnPath.Offset.RightHandSide = "0.164950842901347"

textBuilder1.FrameOnPath.Length.RightHandSide = "0.88893068486898"

textBuilder1.FrameOnPath.Height.RightHandSide = "0.12"

textBuilder1.FrameOnPath.WScale = 195.489959647097

textBuilder1.CanProjectCurves = True

textBuilder1.SelectFont("Arial Narrow", Features.TextBuilder.ScriptOptions.Western)

textBuilder1.TextString = "34"

theSession.SetUndoMarkName(markId1, "Text Dialog")

textBuilder1.Type = Features.TextBuilder.Types.OnFace

textBuilder1.TextString = "z"

textBuilder1.TextString = "zz"

textBuilder1.TextString = "zzz"

textBuilder1.TextString = "zz"

textBuilder1.TextString = "z"

textBuilder1.TextString = ""

textBuilder1.TextString = "Z"

textBuilder1.TextString = "ZZ"

textBuilder1.TextString = "ZZZ"

textBuilder1.TextString = "ZZZ-"

Dim rotMatrix1 As Matrix3x3
rotMatrix1.Xx = -0.469034724190536
rotMatrix1.Xy = 0.0657761499452957
rotMatrix1.Xz = 0.880726930212697
rotMatrix1.Yx = 0.652416079343396
rotMatrix1.Yy = 0.697953289734047
rotMatrix1.Yz = 0.295320952124318
rotMatrix1.Zx = -0.595281183070404
rotMatrix1.Zy = 0.713116192108828
rotMatrix1.Zz = -0.370277746609899
Dim translation1 As Point3d = New Point3d(5.66522755412006, -0.658546753678755, -1.31973178094156)
workPart.ModelingViews.WorkView.SetRotationTranslationScale(rotMatrix1, translation1, 0.608673963940151)

textBuilder1.TextString = "ZZZ-Z"

textBuilder1.TextString = "ZZZ-ZZ"

textBuilder1.TextString = "ZZZ-ZZZ"

textBuilder1.TextString = "ZZZ-ZZZZ"

textBuilder1.TextString = "ZZZ-ZZZZZ"

textBuilder1.TextString = "ZZZ-ZZZZZZ"

textBuilder1.TextString = "ZZZ-ZZZZZZ-"

textBuilder1.TextString = "ZZZ-ZZZZZZ-Z"

textBuilder1.TextString = "ZZZ-ZZZZZZ-ZZ"

textBuilder1.TextString = "ZZZ-ZZZZZZ-ZZZ"

textBuilder1.TextString = "ZZZ-ZZZZZZ-ZZZ "

textBuilder1.TextString = "ZZZ-ZZZZZZ-ZZZ R"

textBuilder1.TextString = "ZZZ-ZZZZZZ-ZZZ RE"

textBuilder1.TextString = "ZZZ-ZZZZZZ-ZZZ REV"

textBuilder1.TextString = "ZZZ-ZZZZZZ-ZZZ REV?"

textBuilder1.TextString = "ZZZ-ZZZZZZ-ZZZ REV??"

textBuilder1.TextString = "ZZZ-ZZZZZZ-ZZZ REV?? "

textBuilder1.TextString = "ZZZ-ZZZZZZ-ZZZ REV?? X"

textBuilder1.TextString = "ZZZ-ZZZZZZ-ZZZ REV?? XX"

textBuilder1.TextString = "ZZZ-ZZZZZZ-ZZZ REV?? XXX"

textBuilder1.TextString = "ZZZ-ZZZZZZ-ZZZ REV?? XXXX"

textBuilder1.TextString = "ZZZ-ZZZZZZ-ZZZ REV?? XXXXX"

textBuilder1.TextString = "ZZZ-ZZZZZZ-ZZZ REV?? XXXXXX"

textBuilder1.TextString = "ZZZ-ZZZZZZ-ZZZ REV?? XXXXXX-"

textBuilder1.TextString = "ZZZ-ZZZZZZ-ZZZ REV?? XXXXXX-Y"

textBuilder1.TextString = "ZZZ-ZZZZZZ-ZZZ REV?? XXXXXX-YY"

' ----------------------------------------------
' Menu: Tools->Journal->Stop Recording
' ----------------------------------------------

End Sub
End Module

Based on the information in the first post, I assumed we were dealing with a drafting object (note, tabular note, balloon, etc); these objects all refer to the font table. Apparently, the text function in modeling uses a different scheme. The following line of your code specifies the font to use:

textBuilder1.SelectFont("Arial Narrow", Features.TextBuilder.ScriptOptions.Western)

The good news is that the journal specifies the font by name rather than "option 65 in the list" as the macro does. I'm not entirely sure what will happen if the specified font is not installed on the computer; I'd guess that it will try to fall back on a similar font (Windows groups similar fonts into "font families"). The journal samples above are based on VB.net, as such they have access to much of the .net framework; if desired, you can easily query the installed fonts on the computer and take action based on your findings.

Here is an MSDN article that shows how to query the installed fonts:
https://msdn.microsoft.com/en-us/library/0yf5t4e8(v=vs.110).aspx

Thank you so much for your patience and understanding. I've learned a lot and I have my answer. I didn't know journal was different in macros when it came to fonts.
I know that SNAP is feature based. So is there a rule. Use a Macro when you want to do this?, Use a Journal when you want to do this?, Use SNAP when you want to do this?

Thank you for your input!

The big difference between macros and journaling is that a macro is essentially a mouse/keystroke recorder while a journal calls the underlying internal NX functions. Using your "text curve" macro as an example, you can see where it records all of the current values for the available options in the dialog and records the new values that you change. Even with the short comment at the end of each line, it is very difficult to tell what the user is up to. When selecting the font, the macro returned #65 of the available choices. When run, the macro recreates the user's dialog choices and passes them on to NX. By contrast, journaling calls the underlying NX function directly. The journal code is independent of the corresponding function dialog.

Both macros and journals are tools to help automate tasks in NX. Personally, I tend to use journals where possible as I find them easier to write, maintain, extend, and reuse; but there are a few instances where macros have the advantage. For example, changing drafting settings can be easier with a macro than a journal (at least this used to be the case, I've not tried it recently).

SNAP is essentially the same as journaling, but easier; it streamlines many common function calls. Something that may take several lines of code in a journal may only be one or two lines of code with SNAP. SNAP is intended as a replacement for the old GRIP language, which was a proprietary language embedded in NX meant to help automate some common tasks. GRIP was programming for the (slightly above) average NX user. If you have a SNAP license, you can use SNAP function calls alongside other NXOpen function calls. SNAP is a relatively new addition to NX, it came about in NX 8 if I remember correctly. More functions are added to SNAP with each NX release, but it doesn't cover everything available in the NXOpen API.

I tried to create the above using Journaling but it doesn't seem to be working. Below is the text from the journal. Any ideas on whats wrong?

' NX 8.5.3.3
' Journal created by martili on Wed Sep 14 09:14:26 2016 Pacific Daylight Time
'
Option Strict Off
Imports System
Imports NXOpen

Module NXJournal
Sub Main (ByVal args() As String)

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

Dim displayPart As Part = theSession.Parts.Display

' ----------------------------------------------
' Menu: Insert->Curve->Text...
' ----------------------------------------------
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Start")

Dim nullFeatures_Text As Features.Text = Nothing

If Not workPart.Preferences.Modeling.GetHistoryMode Then
Throw(New Exception("Create or edit of a Feature was recorded in History Mode but playback is in History-Free Mode."))
End If

Dim textBuilder1 As Features.TextBuilder
textBuilder1 = workPart.Features.CreateTextBuilder(nullFeatures_Text)

Dim origin1 As Point3d = New Point3d(0.0, 0.0, 0.0)
Dim normal1 As Vector3d = New Vector3d(0.0, 0.0, 1.0)
Dim plane1 As Plane
plane1 = workPart.Planes.CreatePlane(origin1, normal1, SmartObject.UpdateOption.WithinModeling)

textBuilder1.SectionPlane = plane1

Dim unit1 As Unit
unit1 = textBuilder1.PlanarFrame.Length.Units

Dim expression1 As Expression
expression1 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)

Dim expression2 As Expression
expression2 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)

Dim coordinates1 As Point3d = New Point3d(0.0, 0.0, 0.0)
Dim point1 As Point
point1 = workPart.Points.CreatePoint(coordinates1)

textBuilder1.FrameOnPath.AnchorPosition.Expression.RightHandSide = "50"

textBuilder1.SelectFont("Arial", Features.TextBuilder.ScriptOptions.Western)

textBuilder1.TextString = "Text"

theSession.SetUndoMarkName(markId1, "Text Dialog")

textBuilder1.Destroy()

Try
' Expression is still in use.
workPart.Expressions.Delete(expression2)
Catch ex As NXException
ex.AssertErrorCode(1050029)
End Try

Try
' Expression is still in use.
workPart.Expressions.Delete(expression1)
Catch ex As NXException
ex.AssertErrorCode(1050029)
End Try

plane1.DestroyPlane()

theSession.UndoToMark(markId1, Nothing)

theSession.DeleteUndoMark(markId1, Nothing)

Dim markId2 As Session.UndoMarkId
markId2 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Start")

Dim textBuilder2 As Features.TextBuilder
textBuilder2 = workPart.Features.CreateTextBuilder(nullFeatures_Text)

Dim origin2 As Point3d = New Point3d(0.0, 0.0, 0.0)
Dim normal2 As Vector3d = New Vector3d(0.0, 0.0, 1.0)
Dim plane2 As Plane
plane2 = workPart.Planes.CreatePlane(origin2, normal2, SmartObject.UpdateOption.WithinModeling)

textBuilder2.SectionPlane = plane2

Dim expression3 As Expression
expression3 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)

Dim expression4 As Expression
expression4 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)

Dim coordinates2 As Point3d = New Point3d(0.0, 0.0, 0.0)
Dim point2 As Point
point2 = workPart.Points.CreatePoint(coordinates2)

textBuilder2.FrameOnPath.AnchorPosition.Expression.RightHandSide = "50"

textBuilder2.SelectFont("Arial", Features.TextBuilder.ScriptOptions.Western)

textBuilder2.TextString = "Text"

theSession.SetUndoMarkName(markId2, "Text Dialog")

' ----------------------------------------------
' Dialog Begin Text
' ----------------------------------------------
textBuilder2.Type = Features.TextBuilder.Types.OnFace

textBuilder2.SelectFont("Arial Narrow", Features.TextBuilder.ScriptOptions.Western)

textBuilder2.TextString = "T"

textBuilder2.TextString = "Th"

textBuilder2.TextString = "Thi"

textBuilder2.TextString = "This"

textBuilder2.TextString = "This "

textBuilder2.TextString = "This i"

textBuilder2.TextString = "This is"

textBuilder2.TextString = "This is "

textBuilder2.TextString = "This is t"

textBuilder2.TextString = "This is th"

textBuilder2.TextString = "This is the"

textBuilder2.TextString = "This is the "

textBuilder2.TextString = "This is the T"

textBuilder2.TextString = "This is the TE"

textBuilder2.TextString = "This is the TEX"

textBuilder2.TextString = "This is the TEXT"

textBuilder2.TextString = "This is the TEXT"

textBuilder2.CanProjectCurves = True

' ----------------------------------------------
' Menu: Tools->Journal->Stop Recording
' ----------------------------------------------

End Sub
End Module

I don't see the text builder "committed" in the code above. It appears that the operation was cancelled or journal recording was stopped before pressing the "OK" button on the dialog.

Thank you for the excellent detail!! Have a good day!!

Eventually I want the user to be able to select this button, text and font will be automatically entered. Also some options will be selected. The user will automatically get the dialog and then they will continue the action. So I want the dialog open when the user selects this button because they will need to define where they place the text on the model.
Thanks for your input!!

That's what I was afraid of...

The good news is that, unlike macros, journal code is not tied to the dialog box. This means that you can specify which font you want to use and rest assured that you will get it no matter which computer the code runs on.

The bad news is that, unlike macros, journal code is not tied to the dialog box. You cannot use a journal to partially fill in dialog box options then leave it open for the user to finish the command. Journals do not allow you to manipulate the NX UI in that way.

You could add some prompts to the journal code to allow user interaction (but it won't be with the text feature dialog box). But it really sounds like you would like to get the NX macro working (picking the correct font each time). There may be a way around the macro font picking problem, unfortunately, I'm not familiar enough with NX macros to answer that question. I suggest asking this question on the Siemens' NX programming and customization forum:

https://community.plm.automation.siemens.com/t5/NX-Programming-Customiza...

Be sure to tell them that you are creating an NX macro to help automate the modeling "text" function and explain about the font issue. There are some expert users there that may be able to provide a solution or work-around.

Thank you for your help, it is greatly appreciated. Do you know if SNAP could do what I'm looking for?

The short answer is no; SNAP won't allow you to manipulate the NX dialogs either.

The longer answer is that SNAP adds a layer between the NXOpen API and the programmer. This layer simplifies and streamlines certain calls to the API; in essence, it is "journaling made easier". However, it does not add any functionality to work with the NX command dialogs as you would like to do.

Ok, thank you so much for your time.