×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

NX9 - Need Help With Journal Code Please

NX9 - Need Help With Journal Code Please

NX9 - Need Help With Journal Code Please

(OP)
I have a journal for workers to hit before working on a new job. It sets up all of the drafting settings that we need in order to keep all of the work done in a similar way for this group. We need to now add to it so it will switch UG over to modeling, select all bodies (Solid bodies, sheet bodies, etc...) and change the Edit-Display settings so the lines are solid, .35 thick.

However, I cant figure out how to make a journal switch over to modeling and then back to drafting after it does what it needs to do to the bodies.

Can anyone please help with this? I have found other threads about similar things but I am having a hard time figuring how to add these to a journal that is already working in drafting preferences. It would not matter if it does this at the beginning of the journal and then sets all the drafting preferences, or if it sets the preferences and then changes the edit display to the bodies at the end.



Here is the Journal I am needing to adjust.....

' NX 9.0.2.5
' Journal created by kschonmeier HMS Company
'
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
'Dark 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("Dark Gray")
preferencesBuilder1.ViewWorkflow.BorderColor = myBorderColor

preferencesBuilder1.ViewWorkflow.PreviewStyle =

Drawings.ViewWorkflowBuilder.Style.Shaded

'Dim fontIndex1 As Integer
'fontIndex1 = workPart.Fonts.AddFont("leroy", FontCollection.Type.Nx)


preferencesBuilder1.TableCellStyle.BorderColor = 212


preferencesBuilder1.ViewStyle.ViewStyleGeneral.ExtractedEdges =
Preferences.GeneralExtractedEdgesOption.None

preferencesBuilder1.ViewStyle.ViewStyleGeneral.ViewRepresentation =
Preferences.GeneralViewRepresentationOption.PreNx85Exact


preferencesBuilder1.ViewStyle.ViewStyleGeneral.AnglePrecision = 0

preferencesBuilder1.ViewStyle.ViewStyleGeneral.AnglePrecision = 1

preferencesBuilder1.ViewStyle.ViewStyleGeneral.AngleDecimalPointCharacter =
Preferences.DecimalPointCharacter.Period

preferencesBuilder1.ViewStyle.ViewStyleGeneral.AngleShowLeadingZeros = True

preferencesBuilder1.ViewStyle.ViewStyleGeneral.AngleShowTrailingZeros = True


preferencesBuilder1.ViewStyle.ViewStyleVisibleLines.VisibleColor =
workPart.Colors.Find(-1)

preferencesBuilder1.ViewStyle.ViewStyleVisibleLines.VisibleColor =
workPart.Colors.Find("Background")

preferencesBuilder1.ViewStyle.ViewStyleHiddenLines.HiddenLine = True

preferencesBuilder1.ViewStyle.ViewStyleHiddenLines.Color = workPart.Colors.Find(-1)

preferencesBuilder1.ViewStyle.ViewStyleHiddenLines.Color = workPart.Colors.Find
("Background")

preferencesBuilder1.ViewStyle.ViewStyleHiddenLines.Font = Preferences.Font.Dashed

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.ViewProjectedLabel.ShowViewLabel = False

preferencesBuilder1.ViewStyle.ViewProjectedViewSettings.DisplayArrowOnParentView =
Drawings.ViewProjectedViewSettingsBuilder.DisplayArrowOnParentViewType.No

preferencesBuilder1.ViewStyle.ViewStyleSection.SheetBodies = True

preferencesBuilder1.ViewStyle.ViewStyleSection.Background = True


preferencesBuilder1.ViewWorkflow.AssociativeAlignment = False


preferencesBuilder1.AnnotationStyle.DimensionStyle.Orientation =
Annotations.TextOrientation.Horizontal

preferencesBuilder1.AnnotationStyle.DimensionStyle.ChamferSeparator =
Annotations.ChamferSeparatorType.UppercaseX

preferencesBuilder1.AnnotationStyle.DimensionStyle.LineBetweenArrows = False

preferencesBuilder1.AnnotationStyle.DimensionStyle.AngularDimensionValuePrecision = 2

preferencesBuilder1.AnnotationStyle.DimensionStyle.DimensionValuePrecision = 2

preferencesBuilder1.AnnotationStyle.DimensionStyle.TextArrowPlacement =
Annotations.TextPlacement.ManualArrowsIn


preferencesBuilder1.AnnotationStyle.LetteringStyle.AlignPosition =
Annotations.AlignmentPosition.TopLeft

preferencesBuilder1.AnnotationStyle.LetteringStyle.HorizontalTextJustification =
Annotations.TextJustification.Center

preferencesBuilder1.AnnotationStyle.LetteringStyle.GeneralTextColor =
workPart.Colors.Find("White")

preferencesBuilder1.AnnotationStyle.LetteringStyle.GeneralTextSize = 2.5

preferencesBuilder1.AnnotationStyle.LetteringStyle.GeneralNxTextCharacterSpaceFactor = 1.0


preferencesBuilder1.AnnotationStyle.LetteringStyle.GeneralStandardTextCharacterSpaceFactor = 0.0

preferencesBuilder1.AnnotationStyle.LetteringStyle.GeneralTextAspectRatio = 1.0

preferencesBuilder1.AnnotationStyle.LetteringStyle.GeneralTextLineSpaceFactor = 1.0

preferencesBuilder1.AnnotationStyle.LetteringStyle.Angle = 0.0


preferencesBuilder1.AnnotationStyle.LineArrowStyle.FirstArrowheadColor =
workPart.Colors.Find("White")

preferencesBuilder1.AnnotationStyle.LineArrowStyle.SecondArrowheadColor =
workPart.Colors.Find("White")

preferencesBuilder1.AnnotationStyle.LineArrowStyle.FirstExtensionLineColor =
workPart.Colors.Find("White")

preferencesBuilder1.AnnotationStyle.LineArrowStyle.SecondExtensionLineColor =
workPart.Colors.Find("White")

preferencesBuilder1.AnnotationStyle.LineArrowStyle.SecondArrowheadColor =
workPart.Colors.Find("White")

preferencesBuilder1.AnnotationStyle.LineArrowStyle.FirstArrowLineColor =
workPart.Colors.Find("White")

preferencesBuilder1.AnnotationStyle.LineArrowStyle.SecondArrowLineColor =
workPart.Colors.Find("White")

preferencesBuilder1.AnnotationStyle.LineArrowStyle.FirstPosToExtensionLineDistance = 1.5

preferencesBuilder1.AnnotationStyle.LineArrowStyle.SecondPosToExtensionLineDistance = 1.5

preferencesBuilder1.AnnotationStyle.LineArrowStyle.FirstArrowType =

Annotations.ArrowheadType.ClosedArrow

preferencesBuilder1.AnnotationStyle.LineArrowStyle.SecondArrowType =

Annotations.ArrowheadType.ClosedArrow

preferencesBuilder1.AnnotationStyle.LineArrowStyle.StubLength = 3.0

preferencesBuilder1.AnnotationStyle.LineArrowStyle.TextToLineDistance = 1.0

preferencesBuilder1.AnnotationStyle.LineArrowStyle.LinePastArrowDistance = 2.0

preferencesBuilder1.AnnotationStyle.OrdinateStyle.DisplayDimensionLine =

Annotations.OrdinateLineArrowDisplayOption.None

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.UnitsStyle.DecimalPointCharacter =

Annotations.DecimalPointCharacter.Period

preferencesBuilder1.AnnotationStyle.UnitsStyle.DisplayTrailingZeros = False

preferencesBuilder1.AnnotationStyle.UnitsStyle.DisplayLeadingDimensionZeros = True

preferencesBuilder1.AnnotationStyle.UnitsStyle.DisplayLeadingToleranceZeros = True

preferencesBuilder1.AnnotationStyle.UnitsStyle.DimensionAngularFormat =

Annotations.AngularDimensionFormat.FractionalDegrees

preferencesBuilder1.AnnotationStyle.HoleCalloutSettings.SetLeaderAttachment

(Annotations.HoleCalloutSettingsBuilder.LeaderAttachment.Top)

preferencesBuilder1.ViewWorkflow.DisplayBorders = True



'Dim letteringPreferences1 As Annotations.LetteringPreferences
'letteringPreferences1 = workPart.Annotations.Preferences.GetLetteringPreferences()

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

preferencesBuilder1.AnnotationStyle.LetteringStyle.AppendedTextSize = 2.5
preferencesBuilder1.AnnotationStyle.LetteringStyle.AppendedTextAspectRatio = 1.0
preferencesBuilder1.AnnotationStyle.LetteringStyle.AppendedTextColor = workPart.Colors.Find
("White")
preferencesBuilder1.AnnotationStyle.LetteringStyle.AppendedNxTextCharacterSpaceFactor = 1.0
preferencesBuilder1.AnnotationStyle.LetteringStyle.AppendedStandardTextCharacterSpaceFactor = 1.0
preferencesBuilder1.AnnotationStyle.LetteringStyle.AppendedTextLineSpaceFactor = 0.6
preferencesBuilder1.AnnotationStyle.LetteringStyle.AppendedTextSpaceFactor = 1.0
preferencesBuilder1.AnnotationStyle.LetteringStyle.AppendedTextLineWidth =

Annotations.LineWidth.Thin

preferencesBuilder1.AnnotationStyle.LetteringStyle.DimensionTextSize = 2.5
preferencesBuilder1.AnnotationStyle.LetteringStyle.DimensionTextAspectRatio = 1.0
preferencesBuilder1.AnnotationStyle.LetteringStyle.DimensionTextColor = workPart.Colors.Find
("White")
preferencesBuilder1.AnnotationStyle.LetteringStyle.DimensionNxTextCharacterSpaceFactor = 1.0
preferencesBuilder1.AnnotationStyle.LetteringStyle.DimensionStandardTextCharacterSpaceFactor = 1.0
preferencesBuilder1.AnnotationStyle.LetteringStyle.DimensionTextLineSpaceFactor = 0.6
preferencesBuilder1.AnnotationStyle.LetteringStyle.DimLineSpaceFactor = 1.0
preferencesBuilder1.AnnotationStyle.LetteringStyle.DimensionTextLineWidth =
Annotations.LineWidth.Thin

preferencesBuilder1.AnnotationStyle.LetteringStyle.ToleranceTextSize = 2.5
preferencesBuilder1.AnnotationStyle.LetteringStyle.ToleranceTextAspectRatio = 1.0
preferencesBuilder1.AnnotationStyle.LetteringStyle.ToleranceTextColor = workPart.Colors.Find
("White")
preferencesBuilder1.AnnotationStyle.LetteringStyle.ToleranceNxTextCharacterSpaceFactor = 1.0
preferencesBuilder1.AnnotationStyle.LetteringStyle.ToleranceStandardTextCharacterSpaceFactor

= 1.0
preferencesBuilder1.AnnotationStyle.LetteringStyle.ToleranceTextLineSpaceFactor = 0.6
preferencesBuilder1.AnnotationStyle.LetteringStyle.ToleranceTextSpaceFactor = 1.0
preferencesBuilder1.AnnotationStyle.LetteringStyle.ToleranceTextLineWidth =
Annotations.LineWidth.Thin

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 Module

RE: NX9 - Need Help With Journal Code Please

The journal does not need to switch applications unless you want to leave the user in a specific application at the end of the journal. You can change drafting and modeling preferences without changing applications.

www.nxjournaling.com

RE: NX9 - Need Help With Journal Code Please

(OP)
But in this case, they are often in Drafting when they run the Set-up button. The portion I wish to add to the journal would not be changing the settings or preferences, it would be changing the actual display of the solids bodies in modeling. I would need to go to Modeling, select all solid bodies, sheet bodies and Facet bodies, and then go to "Edit Display" and change the settings to those bodies.

If I dont switch to modeling to do this, I think I would need to at least turn off the drafting sheet so i can see the solid bodies.

RE: NX9 - Need Help With Journal Code Please

Quote (Kenja824)

I think I would need to at least turn off the drafting sheet so i can see the solid bodies.

Why? Are you selecting the bodies manually, or do you want the journal to automatically process them for you?
If you want the journal to do it, I see no reason to switch to modeling or turn off the drawing sheet.

www.nxjournaling.com

RE: NX9 - Need Help With Journal Code Please

(OP)
The problem is the boss has decided he wants all of our prints from now on to show line thickness. For years we have never worried about that and so every detail and standard component we have made is done with the default of .13 line thickness. He wants it .35 thick.

I have been playing with changing the display properties from drafting. The one problem I run into has to do with layers. In assemblies, we have what we call "open positions" and place those bodies in layer 9 and the lines will need to be phantom and .13 thick. The bodies on layer one will need to be solid lines and .35 thick. When I go to Edit Display from drafting, the only way I know to select the bodies is through the navigator, but if I change the filter to only layer 1, it still allows the layer 9 bodies to be selected and changed.

If there is another way, please let me know.

RE: NX9 - Need Help With Journal Code Please

(OP)
Sorry to bother you with all of this. Feeling stupid as I think I just saw how to do it all. Starting to think my brain is going these days. lol

I dont know why I was thinking I had to select the bodies through the navigator instead of just selecting "Select All". lol

Though I do find it interesting that with the layer filter set to layer 9 only, it allowed me to slect bodies through the navigator on other layers still.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources