Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

Journal ListingWindow question

Status
Not open for further replies.

Ehaviv

Computer
Jul 2, 2003
1,012
0
0
IL
Hi

These journals identical one write to a file only and the second to a file and window
the output of 'write to a file only' have 2 blank lines more then of the 'write to a file and window'
can somone know and explain what hpen

Thanks in advanced.

Journal 1

Code:
Option Strict Off

Imports System
Imports System.IO

Imports NXOpen
Imports NXOpen.UF
 
 Module ListingWindow_SelectDevice_DeviceType_FileAndWindow
 
  Sub Main()
 
    Dim s As Session = Session.GetSession()
    Dim ufs As UFSession = UFSession.GetUFSession
    Dim workPart As Part = s.Parts.Work
    Dim lw As ListingWindow = s.ListingWindow
    Dim nowDateTime As String = Nothing
    Dim window2file As String

    nowDateTime = Format(Now, "_ddMy_hhmmss")
    window2file = "C:\_nx11_\journal_directory\FileAndWindow_" & nowDateTime & ".txt" 

    'use listing window to write to file and window
    lw.SelectDevice(ListingWindow.DeviceType.FileAndWindow, window2file)  

    ufs.Ui.ExitListingWindow()
    lw.Open()
 
    lw.WriteLine("=========================================================")
    lw.WriteLine("")
    lw.WriteLine("ListingWindow.DeviceType.FileAndWindow = " & window2file)
    lw.WriteLine("")
    lw.WriteLine("=========================================================")
 
    lw.Close()
    'flush file buffer by changing listing window device
    lw.SelectDevice(ListingWindow.DeviceType.Window, "")
 
  End Sub
 
 End Module

output 1
Code:
=========================================================

ListingWindow.DeviceType.FileAndWindow = C:\_nx11_\journal_directory\FileAndWindow__05618_073317.txt

=========================================================

*************************************************************************
*************************************************************************

Journal 2

Code:
Option Strict Off

Imports System
Imports System.IO

Imports NXOpen
Imports NXOpen.UF
 
 Module ListingWindow_SelectDevice_DeviceType_File
 
  Sub Main()
 
    Dim s As Session = Session.GetSession()
    Dim ufs As UFSession = UFSession.GetUFSession
    Dim workPart As Part = s.Parts.Work
    Dim lw As ListingWindow = s.ListingWindow
    Dim nowDateTime As String = Nothing
    Dim window2file As String

    nowDateTime = Format(Now, "_ddMy_hhmmss")
    window2file = "C:\_nx11_\journal_directory\File_" & nowDateTime & ".txt" 

    'use listing window to write to file and window
    lw.SelectDevice(ListingWindow.DeviceType.File, window2file) 

    ufs.Ui.ExitListingWindow()
    lw.Open()
 
    lw.WriteLine("=========================================================")
    lw.WriteLine("")
    lw.WriteLine("ListingWindow.DeviceType.File = " & window2file)
    lw.WriteLine("")
    lw.WriteLine("=========================================================")
 
    lw.Close()
    'flush file buffer by changing listing window device
    lw.SelectDevice(ListingWindow.DeviceType.Window, "")
 
  End Sub
 
 End Module

output 2

Code:
=========================================================



ListingWindow.DeviceType.File = C:\_nx11_\journal_directory\File__05618_073702.txt



=========================================================
 
Replies continue below

Recommended for you

Hi

I added some code to work around but I'm still
wonder why this ocurring.


Code:
Option Strict Off

Imports System
Imports System.IO
Imports System.Text.RegularExpressions

Imports NXOpen
Imports NXOpen.UF
 
 Module ListingWindow_SelectDevice_DeviceType_File
 
  Sub Main()
 
    Dim s As Session = Session.GetSession()
    Dim ufs As UFSession = UFSession.GetUFSession
    Dim workPart As Part = s.Parts.Work
    Dim lw As ListingWindow = s.ListingWindow
    Dim nowDateTime As String = Nothing
    Dim window2file As String
    Dim window2file2 As String

    nowDateTime = Format(Now, "_ddMMyy_hhmmss")
    window2file = "C:\_nx11_\journal_directory\File_" & nowDateTime & ".txt" 
    window2file2 = "C:\_nx11_\journal_directory\File_" & nowDateTime & "_2.txt" 

    'use listing window to write to file and window
    lw.SelectDevice(ListingWindow.DeviceType.File, window2file) 

    ufs.Ui.ExitListingWindow()
    lw.Open()
 
    lw.WriteLine("=========================================================")
    lw.WriteLine("")
    lw.WriteLine("")
    lw.WriteLine("")
    lw.WriteLine("ListingWindow.DeviceType.File = " & window2file)
    lw.WriteLine("")
    lw.WriteLine("ListingWindow.DeviceType.File = " & window2file)
    lw.WriteLine("")
    lw.WriteLine("")
    lw.WriteLine("=========================================================")
 
    'flush file buffer by changing listing window device
    lw.SelectDevice(ListingWindow.DeviceType.Window, "")
    lw.Close()

[b]
     Dim sr As System.IO.StreamReader = New System.IO.StreamReader(window2file)
     Dim r_str = sr.ReadToEnd()
     sr.Close()
     r_str = Regex.Replace(r_str, "[\r\n]+", vbCrLf & vbCrLf)

     Dim sw As System.IO.StreamWriter = New System.IO.StreamWriter(window2file2)
     sw.Write(r_str)
     sw.Close()
[/b]
 
  End Sub
 
 End Module
 
I should clarify my previous post. By "identical output", I meant that both of your posted journals give me the exact same result and neither had the extra lines that you are seeing. I do NOT get the extra lines that you are seeing no matter which version of your journal I use. I would suggest contacting GTAC, perhaps it is something in your configuration or a bug in the NXOpen API.

www.nxjournaling.com
 
Hello Ehaviv,

It isn't clear (to me) if maintenance pack MP7 (or mp8 or mp9 or mp10) is installed in addition to the 11.0.2.7. maintenance release. There were listing window changes delivered in MP7. (Just making sure that this seven 11.0.2.[highlight #FCE94F]7[/highlight] is not being misinterpreted as meaning MP7).

HTH, Joe
 
Status
Not open for further replies.
Back
Top