A new NX9 JOURNAL question
A new NX9 JOURNAL question
(OP)
I have a Journal that fixes a bunch of Drafting Settings for us. I tested it on four different computers and it worked perfect, so I sent out an email for everyone to go ahead and use it. Shortly after, someone told me it changed the font to "NX ANSI Symbols" when it is set up to change it to "Leroy". My guess was that that computer might need an update to a patch or something, but then the next day, it happened to me. Right now I have a file in Team Center that if I run it, the Font will change to Leroy, as it should. But if I go to one of the new details I created for this file and run the Journal, it changes the font to the NX Ansi Symbols.
Why would it change it to Leroy on some files (Possibly only older files) but to NX Ansi Symbols on other files (Possibly newly created files)?
Why would it change it to Leroy on some files (Possibly only older files) but to NX Ansi Symbols on other files (Possibly newly created files)?





RE: A new NX9 JOURNAL question
If so, it appears that the font was added to the NX file, but the journal doesn't tell NX where to use the font. The following code snippet adds the "leroy" font and sets it as the default for dimension text, appended text, tolerance text, and general text. Note that it will set the default for new notes and dimensions, it will not change the font of existing notes or dimensions.
CODE
Dim letteringPreferences1 As Annotations.LetteringPreferences letteringPreferences1 = workPart.Annotations.Preferences.GetLetteringPreferences() Dim fontIndex1 As Integer fontIndex1 = workPart.Fonts.AddFont("leroy", FontCollection.Type.Nx) Dim dimensionText1 As Annotations.Lettering dimensionText1.Cfw.Font = fontIndex1 letteringPreferences1.SetDimensionText(dimensionText1) Dim appendedText1 As Annotations.Lettering appendedText1.Cfw.Font = fontIndex1 letteringPreferences1.SetAppendedText(appendedText1) Dim toleranceText1 As Annotations.Lettering toleranceText1.Cfw.Font = fontIndex1 letteringPreferences1.SetToleranceText(toleranceText1) Dim generalText1 As Annotations.Lettering generalText1.Cfw.Font = fontIndex1 letteringPreferences1.SetGeneralText(generalText1) workPart.Annotations.Preferences.SetLetteringPreferences(letteringPreferences1) letteringPreferences1.Dispose()www.nxjournaling.com
RE: A new NX9 JOURNAL question
preferencesBuilder1.AnnotationStyle.LetteringStyle.AppendedTextFont = 3
preferencesBuilder1.AnnotationStyle.LetteringStyle.DimensionTextFont = 3
preferencesBuilder1.AnnotationStyle.LetteringStyle.ToleranceTextFont = 3
In the assembly, which was created in the past, it made the text for all three places "Leroy". But in the two details I created to add to this assembly, it would change the text to the NX Ansi Symbols. So just out of curiosity to see what it would give me, I changed one of them to a 4 then ran it. It gave me Leroy on both files. So I changed them all to 4 and it seems to give Leroy to both the old and new files. I dont understand why. Was I extremely lucky to just use the number that fixed it?
Either way, I am thinking I would be better served to use the code you gave me in the long run. lol But I would be curious to what your thoughts are on why the number 4 seemed to fix it.
RE: A new NX9 JOURNAL question
CODE
Dim fontIndex1 As Integer fontIndex1 = workPart.Fonts.AddFont("leroy", FontCollection.Type.Nx) ' Font is associated with integer 4 Dim dimensionText1 As Annotations.Lettering dimensionText1.Cfw.Font = 4 letteringPreferences1.SetDimensionText(dimensionText1)This is a case where the journal recorder isn't doing you a favor. In this case, the .AddFont method returned the value "4". Instead of using the fontIndex1 variable in the font definition, it uses the literal value of "4". When we run this code on another part, it will assign whatever font has the index of "4" to the dimension text; this may be the leroy font (if we are lucky), but probably will not be.
www.nxjournaling.com
RE: A new NX9 JOURNAL question
Here is your code with a little of what I already have on it to show where I placed it.
-----------------------------------------------------------------------
preferencesBuilder1.AnnotationStyle.HoleCalloutSettings.SetLeaderAttachment(Annotations.HoleCalloutSettingsBuilder.LeaderAttachment.Top)
'dim fontIndex2 As Integer
'fontIndex2 = workPart.Fonts.AddFont("leroy", FontCollection.Type.Nx)
preferencesBuilder1.AnnotationStyle.LetteringStyle.AppendedTextSize = 2.5
preferencesBuilder1.AnnotationStyle.LetteringStyle.DimensionTextSize = 2.5
preferencesBuilder1.AnnotationStyle.LetteringStyle.ToleranceTextSize = 2.5
Dim letteringPreferences1 As Annotations.LetteringPreferences
letteringPreferences1 = workPart.Annotations.Preferences.GetLetteringPreferences()
Dim fontIndex1 As Integer
fontIndex1 = workPart.Fonts.AddFont("leroy", FontCollection.Type.Nx)
Dim dimensionText1 As Annotations.Lettering
dimensionText1.Cfw.Font = fontIndex1
letteringPreferences1.SetDimensionText(dimensionText1)
Dim appendedText1 As Annotations.Lettering
appendedText1.Cfw.Font = fontIndex1
letteringPreferences1.SetAppendedText(appendedText1)
Dim toleranceText1 As Annotations.Lettering
toleranceText1.Cfw.Font = fontIndex1
letteringPreferences1.SetToleranceText(toleranceText1)
Dim generalText1 As Annotations.Lettering
generalText1.Cfw.Font = fontIndex1
letteringPreferences1.SetGeneralText(generalText1)
workPart.Annotations.Preferences.SetLetteringPreferences(letteringPreferences1)
letteringPreferences1.Dispose()
Dim nXObject1 As NXObject
nXObject1 = preferencesBuilder1.Commit()
theSession.SetUndoMarkName(markId1, "Drafting Preferences")
preferencesBuilder1.Destroy()
RE: A new NX9 JOURNAL question
CODE
www.nxjournaling.com
RE: A new NX9 JOURNAL question
With the fixes I did, the Journal now runs through without an error, but its not changing anything. I went in and set the font to something strange, made the height 3.5 and changed the aspect ratio to 4 just to see if it put everthing to how it should be. Not one item changed back to the correct information.
Again, I do appreciate the help. I know it might become aggrivating to try to teach someone so much over the internet like this. lol
RE: A new NX9 JOURNAL question
CODE
Dim fontIndex1 As Integer fontIndex1 = workPart.Fonts.AddFont("leroy", FontCollection.Type.Nx) preferencesBuilder1.AnnotationStyle.LetteringStyle.GeneralTextFont = fontIndex1 preferencesBuilder1.AnnotationStyle.LetteringStyle.AppendedTextFont = fontIndex1 preferencesBuilder1.AnnotationStyle.LetteringStyle.DimensionTextFont = fontIndex1 preferencesBuilder1.AnnotationStyle.LetteringStyle.ToleranceTextFont = fontIndex1You'll need to add that in after the preferencesBuilder1 object is created and before the changes are committed.
www.nxjournaling.com
RE: A new NX9 JOURNAL question
RE: A new NX9 JOURNAL question
CODE
Option Strict Off Imports System Imports NXOpen Imports NXOpen.UF Module NXJournal Sub Main(ByVal args() As String) Dim theSession As Session = Session.GetSession() Dim theUfSession As UFSession = UFSession.GetUFSession() If IsNothing(theSession.Parts.Work) Then 'active part required Return End If Dim workPart As Part = theSession.Parts.Work Dim markId1 As Session.UndoMarkId markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Start") Dim preferencesBuilder1 As Drafting.PreferencesBuilder preferencesBuilder1 = workPart.SettingsManager.CreatePreferencesBuilder() preferencesBuilder1.ViewStyle.ViewStyleGeneral.Silhouettes = True preferencesBuilder1.ViewStyle.ViewStyleGeneral.Centerlines = False 'find closest NX color in display part color table 'Iron Gray (R,G,B) = 76, 76, 76 Dim colorValues(2) As Double colorValues(0) = 76 / 255 colorValues(1) = 76 / 255 colorValues(2) = 76 / 255 Dim closeColor As Integer theUfSession.Disp.AskClosestColor(UFConstants.UF_DISP_rgb_model, colorValues, UFConstants.UF_DISP_CCM_EUCLIDEAN_DISTANCE, closeColor) Dim myBorderColor As NXColor myBorderColor = workPart.Colors.Find(closeColor) 'preferencesBuilder1.ViewWorkflow.BorderColor = workPart.Colors.Find("Iron Gray") preferencesBuilder1.ViewWorkflow.BorderColor = myBorderColor preferencesBuilder1.ViewStyle.ViewStyleVisibleLines.VisibleColor = workPart.Colors.Find(-1) preferencesBuilder1.ViewStyle.ViewStyleVisibleLines.VisibleColor = workPart.Colors.Find("Background") preferencesBuilder1.ViewStyle.ViewStyleHiddenLines.Color = workPart.Colors.Find(-1) preferencesBuilder1.ViewStyle.ViewStyleHiddenLines.Color = workPart.Colors.Find("Background") preferencesBuilder1.ViewStyle.ViewStyleHiddenLines.EdgesHiddenByEdges = True preferencesBuilder1.ViewStyle.ViewStyleSmoothEdges.Color = workPart.Colors.Find(-1) preferencesBuilder1.ViewStyle.ViewStyleSmoothEdges.Color = workPart.Colors.Find("Background") preferencesBuilder1.ViewStyle.ViewStyleSmoothEdges.SmoothEdge = False preferencesBuilder1.ViewStyle.ViewProjectedViewSettings.DisplayArrowOnParentView = Drawings.ViewProjectedViewSettingsBuilder.DisplayArrowOnParentViewType.No preferencesBuilder1.ViewStyle.ViewStyleSection.SheetBodies = True preferencesBuilder1.ViewStyle.ViewStyleSection.Background = True preferencesBuilder1.AnnotationStyle.UnitsStyle.DisplayTrailingZeros = False preferencesBuilder1.AnnotationStyle.DimensionStyle.ChamferSeparator = Annotations.ChamferSeparatorType.UppercaseX preferencesBuilder1.AnnotationStyle.DimensionStyle.LineBetweenArrows = False preferencesBuilder1.AnnotationStyle.OrdinateStyle.PositiveDirection = Annotations.OrdinatePositiveDirection.UpperRight preferencesBuilder1.AnnotationStyle.OrdinateStyle.DisplayNameStyle = Annotations.OrdinateOriginDisplayOption.NoText preferencesBuilder1.AnnotationStyle.OrdinateStyle.OrdinateTextOrientation = Annotations.TextOrientation.Aligned preferencesBuilder1.AnnotationStyle.OrdinateStyle.DoglegAngle = 1.13446401379631 preferencesBuilder1.AnnotationStyle.HoleCalloutSettings.SetLeaderAttachment(Annotations.HoleCalloutSettingsBuilder.LeaderAttachment.Top) Dim fontIndex1 As Integer fontIndex1 = workPart.Fonts.AddFont("leroy", FontCollection.Type.Nx) preferencesBuilder1.AnnotationStyle.LetteringStyle.DimensionTextFont = fontIndex1 preferencesBuilder1.AnnotationStyle.LetteringStyle.AppendedTextFont = fontIndex1 preferencesBuilder1.AnnotationStyle.LetteringStyle.ToleranceTextFont = fontIndex1 preferencesBuilder1.AnnotationStyle.LetteringStyle.GeneralTextFont = fontIndex1 Dim nXObject1 As NXObject nXObject1 = preferencesBuilder1.Commit() theSession.SetUndoMarkName(markId1, "Drafting Preferences") preferencesBuilder1.Destroy() ' ---------------------------------------------- ' Menu: Edit->Sheet... ' ---------------------------------------------- Dim markId4 As Session.UndoMarkId markId4 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Start") Dim drawingSheet1 As Drawings.DrawingSheet = CType(workPart.DrawingSheets.FindObject("SHT1"), Drawings.DrawingSheet) Dim drawingSheetBuilder1 As Drawings.DrawingSheetBuilder drawingSheetBuilder1 = workPart.DrawingSheets.DrawingSheetBuilder(drawingSheet1) drawingSheetBuilder1.ProjectionAngle = Drawings.DrawingSheetBuilder.SheetProjectionAngle.Third Dim nXObject2 As NXObject nXObject2 = drawingSheetBuilder1.Commit() theSession.SetUndoMarkName(markId4, "Sheet") drawingSheetBuilder1.Destroy() End Sub End Modulewww.nxjournaling.com
RE: A new NX9 JOURNAL question
I did want to set the sizes and such too, but that was easy to figure out once I figured out what was happening. Hopefully this journal is set with what I need.
Thanks again!