Hi
I am trying to create a journal to edit the line font, width and color for single or multiple selections. I have a journal that prompts the user for selection of curves and upon the selecting the curves and clicking ok, the properties are modified. But the reuirement is if there are any pre selected curves, then the selection prompt should not appear and changes should be applied to the line\s upon clicking the journal button directly. Here is the code i have
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpenUI
Module NXJournal
Sub Main
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = Nothing
Dim ufs As UFSession = UFSession.GetUFSession()
Dim mySelectedObjects as NXObject()
Try
displayPart = theSession.Parts.Display
Catch Ex As NXException
ufs.UI().DisplayMessage("Please set drafting mode before running the journal", 1)
Exit Sub
End Try
If IsNothing(displayPart) = True Then
ufs.UI().DisplayMessage("Please set drafting mode before running the journal", 1)
Exit Sub
End If
Dim markId4 As Session.UndoMarkId
markId4 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Edit Object Display")
If SelectObjects("Hey, select multiple somethings", _
mySelectedObjects) = Selection.Response.Ok Then
Dim displayModification1 As DisplayModification
displayModification1 = theSession.DisplayManager.NewDisplayModification()
displayModification1.ApplyToAllFaces = False
displayModification1.ApplyToOwningParts = False
displayModification1.NewLayer = 242
displayModification1.NewColor = 175
displayModification1.NewWidth = DisplayableObject.ObjectWidth.One
displayModification1.NewFont = DisplayableObject.ObjectFont.Solid
Dim count as integer
count = mySelectedObjects.Length-1
Dim objects1(count) As DisplayableObject
Dim i as integer
i=0
For Each mySelObj As NXObject in mySelectedObjects
Dim body1 as Curve= mySelObj
objects1(i) = body1
i=i+1
Next
displayModification1.Apply(objects1)
displayModification1.Dispose()
End if
End Sub
Function SelectObjects(prompt As String, _
ByRef selObj as NXObject()) As Selection.Response
Dim theUI As UI = UI.GetUI
Dim typeArray() As Selection.SelectionType = _
{Selection.SelectionType.All, _
Selection.SelectionType.Curves}
Dim resp As Selection.Response = theUI.SelectionManager.SelectObjects( _
prompt, "Selection", _
Selection.SelectionScope.AnyInAssembly, _
False, typeArray, selobj)
If resp = Selection.Response.ObjectSelected Or _
resp = Selection.Response.ObjectSelectedByName Or _
resp = Selection.Response.OK Then
Return Selection.Response.Ok
Else
return Selection.Response.Cancel
End If
End Function
End Module
re: pre-selected objects
Search the GTAC solution center for nx_api4033; it will show how to access pre-selected objects. You may need your webkey to log into the solution center.