"Clear" the Listing window?

To all

I am debugging a simple a programme I created which uses a UI Styler GUI. It works as intended but while "playing" with what-if the-user-does-this I noticed that by closing the GUI (using the cancel button) and re-opening the GUI to re-run the programme the listing window (theLW) still has all the previous messages (i.e. the previous run). While it is actually useful I'd like to know if there is a way of "wiping clean" theLW when I close it?

The cancel_cb() call back has the following lines


theLW.WriteLine ("End of macro...")
theLW.WriteLine ("-----------------------------------")
theLW.Close()
'Wait for 1 sec so that the user can read the lines above 1000ms (1 sec)
System.Threading.Thread.CurrentThread.Sleep(1000)
theLW.CloseWindow()

Thanks
Regards
JXB

Try the Ui.ExitListingWindow command:

Option Strict Off
Imports System
Imports NXOpen

Module Module1

Sub Main()

Dim theSession As Session = Session.GetSession()
Dim theUfSession As UF.UFSession = UF.UFSession.GetUFSession
Dim theUi As UI = UI.GetUI

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.SelectDevice(ListingWindow.DeviceType.Window, "")
lw.Open()

lw.WriteLine("Hello, world")
lw.Close()

Threading.Thread.Sleep(2000)

'close and clear the listing window
theUfSession.Ui.ExitListingWindow()

End Sub

Public Function GetUnloadOption(ByVal dummy As String) As Integer

'Unloads the image when the NX session terminates
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination

End Function

End Module

Thanks NXJournaling. The answer seems so obvious now that I full a bit "dumb" but it's only because knowing the keyword I could find it in the doc. I'll have to read an "play" a bit with the UFUi Class

Thanks
Regards
JXB

Thanks
Regards

I didn't know about this function until you asked the question and I started searching. It seems like this functionality could have easily been added as a method to the .net listingWindow object or as an extension of the .CloseWindow() method (such as .CloseWindow(True) to close and clear the window, .CloseWindow(False) to just close the window). I don't know why it has been left out. Sometimes the "wrapper" functions give you access to more options that the API developers mysteriously left out of the .net object model.

There are lots of useful functions in NXOpen.UF, so it's definitely worth learning to find your way around.

As is usually the case, the Snap functions are easier to find/use. They have ...
InfoWindow.Close -- closes the window, but does not clear its contents
InfoWindow.Clear -- clears the window, but does not close it

Thanks ciao. Will bear this in mind. just need to find the time to do it. Lunch breaks are not long enough...
I started NX "programing" by looking at SNAP (used the available doc 'getting started with snap rev9.pdf') but dot not have the full SNAP licence so moved on. I am sure the couples of .vb files I have created so far have the option Imports MiniSnap, MiniSnap.Create still in them. I guess there is nothing against mixing up a "normal" .vb with a bit of snap functions, haven't tried yet.

Regards
JXB

Thanks
Regards

There is absolutely nothing wrong (or even strange) about a VB program that calls SNAP functions. A typical VB program will call functions from many different libraries: System.Generics, System.Drawing, NXOpen, NXOpen.UI, and so on. SNAP is just another library; there's nothing special about it.

So, what I always recommend is:
(1) If the functionality you need is available in SNAP, then call the SNAP functions, because that will almost certainly be the easiest.
(2) If the functionality you need is not available in SNAP, then call NX/Open functions instead.

The same advice applies to MiniSnap, too. If it does what you need, then use it. Examples -- MiniSnap has Position and Vector functions that are far superior to anything in NX/Open, and nice simple functions for creating Lines, Circles, Splines, Spheres, Cylinders, etc. Also, the InfoWindow functions are much more convenient than the NX/Open ones. So, use them.