Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Journal to select a single dimension or note, then update it.

Status
Not open for further replies.

mikervmw

Automotive
May 22, 2014
5
I'm stumped on this one.
Probably the simplest one I've needed.

I use journals to set Drafting Preferences for Font, Arrow Size, etc. Everything having to do with text. Here's a sample of one of them.

Code:
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

' ----------------------------------------------
'   Menu: Preferences->Drafting...
' ----------------------------------------------
Dim TEXTSIZE = .0625
Dim TEXTSIZEHALF = TEXTSIZE/2

'Dim FONTNAME = "Arial"
'Dim FONTNUMBER = 1
'''''' Arial's number = 1

Dim FONTNAME = "Verdana"
Dim FONTNUMBER = 5
'''''' Verdana's number = 5

Dim markId1 As NXOpen.Session.UndoMarkId = Nothing
markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Start")
Dim preferencesBuilder1 As NXOpen.Drafting.PreferencesBuilder = Nothing
preferencesBuilder1 = workPart.SettingsManager.CreatePreferencesBuilder()

preferencesBuilder1.AnnotationStyle.LetteringStyle.DimensionTextSize = TEXTSIZE
preferencesBuilder1.AnnotationStyle.LetteringStyle.GeneralTextSize = TEXTSIZE
preferencesBuilder1.AnnotationStyle.LineArrowStyle.ArrowheadLength = TEXTSIZE
preferencesBuilder1.AnnotationStyle.LineArrowStyle.TextOverStubFactor = TEXTSIZE
preferencesBuilder1.AnnotationStyle.LineArrowStyle.StubLength = TEXTSIZE
preferencesBuilder1.AnnotationStyle.LineArrowStyle.TextToLineDistance = TEXTSIZEHALF

preferencesBuilder1.AnnotationStyle.LineArrowStyle.FirstPosToExtensionLineDistance = TEXTSIZEHALF
preferencesBuilder1.AnnotationStyle.LineArrowStyle.SecondPosToExtensionLineDistance = TEXTSIZEHALF
preferencesBuilder1.AnnotationStyle.LineArrowStyle.LinePastArrowDistance = TEXTSIZEHALF
preferencesBuilder1.AnnotationStyle.LineArrowStyle.DatumLengthPastArrow = TEXTSIZEHALF
preferencesBuilder1.AnnotationStyle.LetteringStyle.ToleranceTextSize = TEXTSIZEHALF
preferencesBuilder1.AnnotationStyle.LetteringStyle.TwoLineToleranceTextSize = TEXTSIZEHALF
preferencesBuilder1.AnnotationStyle.LetteringStyle.AppendedTextSize = TEXTSIZE*.9


Dim nXObject1 As NXObject
nXObject1 = preferencesBuilder1.Commit()
theSession.SetUndoMarkName(markId1, "Drafting Preferences")
preferencesBuilder1.Destroy()

' ----------------------------------------------

Dim markId2 As NXOpen.Session.UndoMarkId = Nothing
markId2 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Start")
Dim preferencesBuilder2 As NXOpen.Drafting.PreferencesBuilder = Nothing
preferencesBuilder2 = workPart.SettingsManager.CreatePreferencesBuilder()

Dim fontIndex1 As Integer = Nothing

'fontIndex1 = workPart.Fonts.AddFont("Arial", NXOpen.FontCollection.Type.Standard)
'preferencesBuilder2.AnnotationStyle.LetteringStyle.GeneralTextFont = 1

fontIndex1 = workPart.Fonts.AddFont(FONTNAME, NXOpen.FontCollection.Type.Standard)
preferencesBuilder2.AnnotationStyle.LetteringStyle.GeneralTextFont = FONTNUMBER

Dim fontIndex2 As Integer = Nothing

'fontIndex2 = workPart.Fonts.AddFont("Arial", NXOpen.FontCollection.Type.Standard)
'preferencesBuilder2.AnnotationStyle.LetteringStyle.DimensionTextFont = 1

fontIndex2 = workPart.Fonts.AddFont(FONTNAME, NXOpen.FontCollection.Type.Standard)
preferencesBuilder2.AnnotationStyle.LetteringStyle.DimensionTextFont = FONTNUMBER

Dim nXObject2 As NXOpen.NXObject = Nothing
nXObject2 = preferencesBuilder2.Commit()
theSession.SetUndoMarkName(markId2, "Drafting Preferences")
preferencesBuilder2.Destroy()

End Sub
End Module

I just want to select a dimension or note and update it. Keep doing that until I crash out of the journal.

I've done similar journal for body colors, etc.

Code:
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
 
Module Module1
 
    Sub Main(params() As String)
 
        Dim theSession As Session = Session.GetSession()
        Dim lw As ListingWindow = theSession.ListingWindow
        lw.Open()
 
        Dim myBody As Body
 
        Do Until SelectBody("select a body", myBody) = Selection.Response.Cancel
 
			Dim displayModification1 As DisplayModification
			displayModification1 = theSession.DisplayManager.NewDisplayModification()
 
			displayModification1.ApplyToAllFaces = True
 
			displayModification1.ApplyToOwningParts = False
 
			displayModification1.NewColor = 108

'displayModification1.NewTranslucency = 50
 
 
			Dim objects1(0) As DisplayableObject
 
			objects1(0) = myBody
			displayModification1.Apply(objects1)
 
			displayModification1.Dispose()		
 
 
        Loop
 
        lw.Close()
 
    End Sub
 
 
 
 
    Public Function GetUnloadOption(ByVal dummy As String) As Integer
 
        'Unloads the image when the NX session terminates
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination
 
    End Function
 
    Function SelectBody(ByVal prompt As String, ByRef selObj As TaggedObject) As Selection.Response
 
        Dim theUI As UI = UI.GetUI
        Dim title As String = "Select a solid body"
        Dim includeFeatures As Boolean = False
        Dim keepHighlighted As Boolean = False
        Dim selAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific
        Dim cursor As Point3d
        Dim scope As Selection.SelectionScope = Selection.SelectionScope.AnyInAssembly
        Dim selectionMask_array(0) As Selection.MaskTriple
 
        With selectionMask_array(0)
            .Type = UFConstants.UF_solid_type
            .SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_SOLID_BODY
        End With
 
        Dim resp As Selection.Response = theUI.SelectionManager.SelectTaggedObject(prompt, _
         title, scope, selAction, _
         includeFeatures, keepHighlighted, selectionMask_array, _
         selobj, cursor)
        If resp = Selection.Response.ObjectSelected OrElse resp = Selection.Response.ObjectSelectedByName Then
            Return Selection.Response.Ok
        Else
            Return Selection.Response.Cancel
        End If
 
    End Function	
 
 
End Module

I am just drawing a blank on this one.
Thank you for all the help in the past!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor