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:
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:
>> 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 =