Skip to main content

How to catch transient error messages in ZOS-API


Forum|alt.badge.img+2

When using OpticStudio interface, it can sometimes display an error message.

In ZOS-API, there are some methods under the IZOSAPI_Application Interface that allows to retrieve transient error messages:

bool IsLoggingMessages { get; }
void ClearMessageLog();
bool BeginMessageLogging();
bool EndMessageLogging();
string RetrieveLogMessages();

The general workflow is prior to whatever operation will generate the message you need to call BeginMessageLogging(), after the operation call RetreiveLogMessages(), then call EndMessageLogging().
These properties were added as 'feature experiments'.

 

For example, let's create an error in the file: '{Zemax}\Samples\Sequential\Objectives\Wide angle lens 210 degree field.zmx'. I am adding the field X=0, Y=120, Weight=1. It creates the error “Cannot determine object coordinates!”.
I am now going to read that message in Matlab. I create a connection with the Interactive Extension.
My lines in Matlab are the following:

>> TheApplication=ans;
>> TheSystem=TheApplication.PrimarySystem;
>> MyField=TheSystem.SystemData.Fields;
>> MyField.AddField(0,120,1);
>> TheApplication.BeginMessageLogging();
>> MyField.AddField(0,120,1);
>> TheApplication.RetrieveLogMessages()
ans =
Cannot determine object coordinates!
>> TheApplication.ClearMessageLog();
>> TheApplication.RetrieveLogMessages()
ans =
 
Did this topic help you find an answer to your question?

0 replies

Be the first to reply!

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings