×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Contact US

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!

*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

Journal only works for one note?

Journal only works for one note?

Journal only works for one note?

(OP)
I have merged a couple different journals I have. I want it to let the user select some notes. Often this will be done by windowing around a group of notes. Then it will change their font and other settings.

However, I only got it to the point where if I select one note it works. If I window around multiple notes, it only changes one of them. Can someone please help me make it so it makes the changes to all the notes that are selected?


CODE -->

Option Strict Off
Imports System
Imports System.Collections.Generic
Imports NXOpen
Imports NXOpen.UF

Module Module2

    Dim theSession As Session = Session.GetSession()
    Dim theUfSession As UFSession = UFSession.GetUFSession()
    Dim workPart As NXOpen.Part = theSession.Parts.Work

    Dim lw As ListingWindow = theSession.ListingWindow

    Sub Main()

        If IsNothing(theSession.Parts.BaseWork) Then
            'active part required
            Return
        End If

        Dim markId1 As Session.UndoMarkId
        markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Mirror Note")
        theSession.SetUndoMarkName(markId1, "Class Selection Dialog") 'ADDED*********

        Const nxjID As String = "b4310398-97e3-4726-9b7a-2a998d9da13b"
        theSession.LogFile.WriteLine("NXJID: " & nxjID)

        lw.Open()

        Dim notesAndLabels As New List(Of Annotations.NoteBase)
        Dim num_obj As Integer = 0
        Dim objtags As Tag() = Nothing
        theUfSession.Ui.AskGlobalSelObjectList(num_obj, objtags)

        If num_obj > 0 Then
            'process preselected objects
            For Each temp As Tag In objtags
                Dim tempTaggedObj As TaggedObject = theSession.GetObjectManager.GetTaggedObject(temp)
                If TypeOf (tempTaggedObj) Is NXOpen.Annotations.Note OrElse TypeOf (tempTaggedObj) Is NXOpen.Annotations.Label Then
                    notesAndLabels.Add(tempTaggedObj)
                End If
            Next
        End If

        If notesAndLabels.Count = 0 Then
            'no preselected objects, prompt for selection
            If SelectNotesLabels("Select Notes and/or Labels", notesAndLabels) = Selection.Response.Cancel Then
                'user pressed cancel
                Return
            End If
        End If


        Dim objects1(0) As NXOpen.DisplayableObject

        objects1(0) = notesAndLabels(0)
        Dim editSettingsBuilder1 As NXOpen.Annotations.EditSettingsBuilder = Nothing
        editSettingsBuilder1 = workPart.SettingsManager.CreateAnnotationEditSettingsBuilder(objects1)


        Dim editsettingsbuilders1(0) As NXOpen.Drafting.BaseEditSettingsBuilder
        editsettingsbuilders1(0) = editSettingsBuilder1
        workPart.SettingsManager.ProcessForMultipleObjectsSettings(editsettingsbuilders1)

        Dim fontIndex1 As Integer = Nothing
        fontIndex1 = workPart.Fonts.AddFont("Arial Unicode MS", NXOpen.FontCollection.Type.Standard)

        editSettingsBuilder1.AnnotationStyle.LetteringStyle.GeneralTextFont = 1
        editSettingsBuilder1.AnnotationStyle.LetteringStyle.GeneralTextLineWidth = NXOpen.Annotations.LineWidth.Thin
        editSettingsBuilder1.AnnotationStyle.LetteringStyle.GeneralTextSize = 2.0
        editSettingsBuilder1.AnnotationStyle.LetteringStyle.GeneralTextAspectRatio = 1.0
        editSettingsBuilder1.AnnotationStyle.LetteringStyle.GeneralTextLineSpaceFactor = 0.5


        Dim nXObject1 As NXOpen.NXObject = Nothing
        nXObject1 = editSettingsBuilder1.Commit()

        editSettingsBuilder1.Destroy()



        lw.Close()

    End Sub

    Function SelectNotesLabels(ByVal prompt As String, ByRef selList As List(Of Annotations.NoteBase)) As Selection.Response

        selList.Clear()
        Dim theUI As UI = UI.GetUI
        Dim title As String = "Select Notes and/or Labels"
        Dim includeFeatures As Boolean = False
        Dim keepHighlighted As Boolean = False
        Dim selAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific
        Dim scope As Selection.SelectionScope = Selection.SelectionScope.WorkPart
        Dim selectionMask_array(1) As Selection.MaskTriple
        Dim selObj() As TaggedObject

        With selectionMask_array(0)
            .Type = UFConstants.UF_drafting_entity_type
            .Subtype = UFConstants.UF_draft_note_subtype
        End With

        With selectionMask_array(1)
            .Type = UFConstants.UF_drafting_entity_type
            .Subtype = UFConstants.UF_draft_label_subtype
        End With

        Dim resp As Selection.Response = theUI.SelectionManager.SelectTaggedObjects(prompt,
        title, scope, selAction,
        includeFeatures, keepHighlighted, selectionMask_array, selObj)
        If resp = Selection.Response.Ok Then
            For Each temp As Annotations.NoteBase In selObj
                selList.Add(temp)
            Next
            Return Selection.Response.Ok
        Else
            Return Selection.Response.Cancel
        End If

    End Function

    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 

Ken
www.OneGodLogic.com
My brain is like a sponge. A sopping wet sponge. When I use it, I seem to lose more than I soak in.

RE: Journal only works for one note?

Try this one.

CODE

Option Strict Off
Imports System
Imports System.Collections.Generic
Imports NXOpen
Imports NXOpen.UF

Module Module2

    Dim theSession As Session = Session.GetSession()
    Dim theUfSession As UFSession = UFSession.GetUFSession()
    Dim workPart As NXOpen.Part = theSession.Parts.Work

    Dim lw As ListingWindow = theSession.ListingWindow

    Sub Main()

        If IsNothing(theSession.Parts.BaseWork) Then
            'active part required
            Return
        End If

        Dim markId1 As Session.UndoMarkId
        markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Mirror Note")
        theSession.SetUndoMarkName(markId1, "Class Selection Dialog") 'ADDED*********

        Const nxjID As String = "611e24cc-577f-4d82-87b7-379db54b06c2"
        theSession.LogFile.WriteLine("NXJID: " & nxjID)

        lw.Open()

        Dim notesAndLabels As New List(Of Annotations.NoteBase)
        Dim num_obj As Integer = 0
        Dim objtags As Tag() = Nothing
        theUfSession.Ui.AskGlobalSelObjectList(num_obj, objtags)

        If num_obj > 0 Then
            'process preselected objects
            For Each temp As Tag In objtags
                Dim tempTaggedObj As TaggedObject = theSession.GetObjectManager.GetTaggedObject(temp)
                If TypeOf (tempTaggedObj) Is NXOpen.Annotations.Note OrElse TypeOf (tempTaggedObj) Is NXOpen.Annotations.Label Then
                    notesAndLabels.Add(tempTaggedObj)
                End If
            Next
        End If

        If notesAndLabels.Count = 0 Then
            'no preselected objects, prompt for selection
            If SelectNotesLabels("Select Notes and/or Labels", notesAndLabels) = Selection.Response.Cancel Then
                'user pressed cancel
                Return
            End If
        End If

        For each tempNote as Annotations.NoteBase in notesAndLabels
		    
            Dim editSettingsBuilder1 As NXOpen.Annotations.EditSettingsBuilder = Nothing
            editSettingsBuilder1 = workPart.SettingsManager.CreateAnnotationEditSettingsBuilder({tempNote})
		    
		    
            Dim editsettingsbuilders1(0) As NXOpen.Drafting.BaseEditSettingsBuilder
            editsettingsbuilders1(0) = editSettingsBuilder1
            workPart.SettingsManager.ProcessForMultipleObjectsSettings(editsettingsbuilders1)
		    
            Dim fontIndex1 As Integer = Nothing
            fontIndex1 = workPart.Fonts.AddFont("Arial Unicode MS", NXOpen.FontCollection.Type.Standard)
		    
            editSettingsBuilder1.AnnotationStyle.LetteringStyle.GeneralTextFont = 1
            editSettingsBuilder1.AnnotationStyle.LetteringStyle.GeneralTextLineWidth = NXOpen.Annotations.LineWidth.Thin
            editSettingsBuilder1.AnnotationStyle.LetteringStyle.GeneralTextSize = 2.0
            editSettingsBuilder1.AnnotationStyle.LetteringStyle.GeneralTextAspectRatio = 1.0
            editSettingsBuilder1.AnnotationStyle.LetteringStyle.GeneralTextLineSpaceFactor = 0.5
		    
		    
            Dim nXObject1 As NXOpen.NXObject = Nothing
            nXObject1 = editSettingsBuilder1.Commit()
		    
            editSettingsBuilder1.Destroy()
		    
        Next


        lw.Close()

    End Sub

    Function SelectNotesLabels(ByVal prompt As String, ByRef selList As List(Of Annotations.NoteBase)) As Selection.Response

        selList.Clear()
        Dim theUI As UI = UI.GetUI
        Dim title As String = "Select Notes and/or Labels"
        Dim includeFeatures As Boolean = False
        Dim keepHighlighted As Boolean = False
        Dim selAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific
        Dim scope As Selection.SelectionScope = Selection.SelectionScope.WorkPart
        Dim selectionMask_array(1) As Selection.MaskTriple
        Dim selObj() As TaggedObject

        With selectionMask_array(0)
            .Type = UFConstants.UF_drafting_entity_type
            .Subtype = UFConstants.UF_draft_note_subtype
        End With

        With selectionMask_array(1)
            .Type = UFConstants.UF_drafting_entity_type
            .Subtype = UFConstants.UF_draft_label_subtype
        End With

        Dim resp As Selection.Response = theUI.SelectionManager.SelectTaggedObjects(prompt,
        title, scope, selAction,
        includeFeatures, keepHighlighted, selectionMask_array, selObj)
        If resp = Selection.Response.Ok Then
            For Each temp As Annotations.NoteBase In selObj
                selList.Add(temp)
            Next
            Return Selection.Response.Ok
        Else
            Return Selection.Response.Cancel
        End If

    End Function

    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 

www.nxjournaling.com

RE: Journal only works for one note?

(OP)
Awesome Cowski

Thank you.

I took a little time to compare them. Looks like I had a couple lines that were not needed and you added the For Each code of line with a Next after that section of code. Cant say I fully understand how it all works, but I can kind of see it. lol Maybe by the time I am 85 and considering retirement, I will finally get a grasp of this stuff. lol

Ken
www.OneGodLogic.com
My brain is like a sponge. A sopping wet sponge. When I use it, I seem to lose more than I soak in.

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! Already a Member? Login


Resources

Low-Volume Rapid Injection Molding With 3D Printed Molds
Learn methods and guidelines for using stereolithography (SLA) 3D printed molds in the injection molding process to lower costs and lead time. Discover how this hybrid manufacturing process enables on-demand mold fabrication to quickly produce small batches of thermoplastic parts. Download Now
Design for Additive Manufacturing (DfAM)
Examine how the principles of DfAM upend many of the long-standing rules around manufacturability - allowing engineers and designers to place a part’s function at the center of their design considerations. Download Now
Taking Control of Engineering Documents
This ebook covers tips for creating and managing workflows, security best practices and protection of intellectual property, Cloud vs. on-premise software solutions, CAD file management, compliance, and more. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close