Kenja824
Automotive
- Nov 5, 2014
- 949
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?
Ken
My brain is like a sponge. A sopping wet sponge. When I use it, I seem to lose more than I soak in.
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
My brain is like a sponge. A sopping wet sponge. When I use it, I seem to lose more than I soak in.