Cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing whatever is displayed/printed in the LW?

Phenom
Phenom

To all

 

my memory is not what it used to be.

 

Is there a way of accessing whatever is printed in the LW? consider the following

  1. User "print" information in the LW (assume that it is a new LW and o nly contains what I ma interested)
  2. run a scrip which
  3.    get all the data in the LW
  4.    parse it and extract a couple of numbers
  5. print these numbers in a defined format

Thanks

Regards

Production: NX9.0.3.4, NX10.0.2.6
Development: VB.NET (amateur level !)
6 REPLIES

Re: Accessing whatever is displayed/printed in the LW?

Siemens Phenom Siemens Phenom
Siemens Phenom

You can use ListingWindow.SelectDevice to set the listing window "device" to be a file. Then, anything written to the listing window is written to your chosen file. Then you parse the text in the file to get the information you want.

 

The documentation for the SelectDevice function says:

 

The listing window output can be sent to the Information window of the Unigraphics session, to a file, or to both. Note: file output is buffered. If file output is used, the buffer will not be flushed until the output device is changed again. E.g.

 

There's even some sample code (in C#):

 

ListingWindow.SelectDevice(File, "log.txt") 
ListingWindow.Open() 
ListingWindow.WriteLine("output") 
ListingWindow.Close() 
' buffer is not flushed yet 
ListingWindow.SelectDevice(Window, "") 
' now the buffer is flushed

Personally, I try to avoid this approach, because parsing the text is too hard for me. Sometimes you can find a function that returns info to the caller, rather than writing it to the ListingWindow. But, sometimes you can't.

山田
yamada

Re: Accessing whatever is displayed/printed in the LW?

Phenom
Phenom

Yamada,

 

Thanks for the reply. I am aware if the .SelectDevice but I am not after that. I want the user to do what is required to "print" the data to the LW and then run the script. I don't want to code the "get the raw data" ad it woudl be too complicated. I just want to access whatever is printed in the LW

Production: NX9.0.3.4, NX10.0.2.6
Development: VB.NET (amateur level !)

Re: Accessing whatever is displayed/printed in the LW?

Siemens Phenom Siemens Phenom
Siemens Phenom

I don't think there's a way to do what you want. Once the text has gone to the LW, I don't think there's a way to access it. You have to grab the text as it is being sent to the LW, as I described.

 

Based on Steve's answer below, it looks like I was mistaken. I didn't know about the "Save" function. In .NET it's NXOpen.UF.UFUi.SaveListingWindow.

山田
yamada

Re: Accessing whatever is displayed/printed in the LW?

Phenom
Phenom

Thanks. I suspected so as I couldn't find anything obvious in the doc

Production: NX9.0.3.4, NX10.0.2.6
Development: VB.NET (amateur level !)

Re: Accessing whatever is displayed/printed in the LW?

Siemens Phenom Siemens Phenom
Siemens Phenom

 

You can save the current contents of the window to a temp file with UF_UI_save_listing_window(), or the wrapper method if you are in .Net.  Then you can parse the file and extract the data as required.

Re: Accessing whatever is displayed/printed in the LW?

Phenom
Phenom

thanks for that Steve. This could work fine as I can delete/overwrite the file once processed.

 

Having reviewed what I have I decided against writing the script for Nx and instead tweak an excel macro I already have to parse the type of data I am interested. I will simply save the LW data to a txt file and run my excel macro. A couple of manual steps added but it will make my life easier in the meantime

Production: NX9.0.3.4, NX10.0.2.6
Development: VB.NET (amateur level !)