How to catch transient error messages in ZOS-API

  • 17 July 2020
  • 0 replies
  • 55 views

Userlevel 6
Badge +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 =

 

0 replies

Be the first to reply!

Reply