' Journal created NX 10.0.2.6
'
Option Strict Off
Imports System
Imports NXOpen

Module NXJournal
 Sub Main (ByVal args() As String)

  Dim theSession As NXOpen.Session = NXOpen.Session.GetSession()
  Dim NxSyslog As LogFile = theSession.LogFile
  Dim MainAssemblyIR as String = "#ItemNameRev#"
  Dim MainAssemblyCLI as String = "#ObjectCliName#"
  Dim PLMPerfSW As New System.Diagnostics.Stopwatch()

  ' ----------------------------------------------
  '  Menu: File ->open...
  ' ----------------------------------------------
  Dim markId1 As NXOpen.Session.UndoMarkId
  markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Start")

  theSession.SetUndoMarkName(markId1, "Part open")
  theSession.DeleteUndoMark(markId1, Nothing)

  NxSyslog.WriteLine("##PLMPerfTimeStartLoad: " + Now.ToString())
  NxSyslog.WriteLine("##PLMPerfLoadTopLevelAP: " + MainAssemblyIR)
  PLMPerfSW.Start()

  theSession.Parts.SetNonmasterSeedPartData(MainAssemblyCLI)

  Dim basePart1 As NXOpen.BasePart
  Dim partLoadStatus1 As NXOpen.PartLoadStatus = nothing
  basePart1 = theSession.Parts.OpenBaseDisplay(MainAssemblyCLI, partLoadStatus1)

  Dim workPart As NXOpen.Part = theSession.Parts.Work
  Dim displayPart As NXOpen.Part = theSession.Parts.Display

  partLoadStatus1.Dispose()

  ' stop perf-stopwatch and write measured time in NX-Syslog file
  PLMPerfSW.Stop()
  '-- 15.10.2020 changed key from ##PLMPerfTime to ##PLMPerfDuration
  NxSyslog.WriteLine("##PLMPerfDuration: " + PLMPerfSW.Elapsed.TotalSeconds.ToString().Replace(",", ".") + " sec")
  NxSyslog.WriteLine("##PLMPerfTimeEndLoad2: " + Now.ToString())

  ' ----------------------------------------------
  '  Menu: Datei->close->all parts
  ' ----------------------------------------------
  theSession.Parts.CloseAll(NXOpen.BasePart.CloseModified.CloseModified, Nothing)

  workPart = Nothing
  displayPart = Nothing

 End Sub
End Module
