Submitted by DavideNX990 on Mon, 12/14/2015 - 08:27
Forums:
Hello,
I have a problem with the journal arguments: I've seen in the Journal Manager (the standard NX tool for to launching the jounail files from the graphic interface) that there is a box to insert some arguments that are passed to the journail executed.
The real problem is that i don't know the command in VisualBasic to read those arguments in the jounal file, can you help me to do that?
Thank you.
re: journal arguments
Arguments passed into a journal end up as a string array passed to Sub Main. Your journal code will be responsible for interpreting and parsing the values as needed. Below is a journal that simply prints the arguments passed to it. When using the journal manager to launch this journal, put each argument on its own line in the journal arguments input box (press enter after each argument).
Option Strict Off
Imports System
Imports NXOpen
Module Module1
Sub Main(ByVal args() As String)
Dim theSession As Session = Session.GetSession()
If IsNothing(theSession.Parts.BaseWork) Then
'active part required
Return
End If
Dim workPart As Part = theSession.Parts.Work
Dim lw As ListingWindow = theSession.ListingWindow
lw.Open()
Const undoMarkName As String = "pass arguments journal"
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, undoMarkName)
If String.IsNullOrEmpty(args(0)) Then
lw.WriteLine("no arguments passed to journal")
Return
End If
Dim i As Integer = 1
For Each arg As String In args
lw.WriteLine("argument " & i.ToString & ": " & arg)
i += 1
Next
lw.Close()
End Sub
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