my memory is not what it used to be.
Is there a way of accessing whatever is printed in the LW? consider the following
Solved! Go to Solution.
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.
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
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.
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.
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