switch Mode with ZOS_API or ZPL

  • 25 January 2023
  • 1 reply


is there any ZOS-API or ZPL Command wich is able to switch the mode from non-sequential to sequential? I would like to switch back from non-sequential mode to sequential mode while an interactice extension connection with Matlab is running. 

Another idea would be open a new file in sequential mode. Is it possible to open a new file while the Matlab connection is runnig? So I dont have to open a new file and connect again. Main Target is to keep the process automated via Matlab the whole time. I dont want to use my mouse to change the mode or connect again to Matlab. 

In an early version it was possible to make a macro with a record function, that records my mouse-klicks. In the end I just want to activate buttons, but i dont find the matching commands in ZOS-API and ZPL. 

Thanks, Lukas


Best answer by David.Nguyen 25 January 2023, 15:48

View original

1 reply

Userlevel 7
Badge +2

Hi Lukas,


In ZOS-API, you’ll find the following methods for the optical system (TheSystem) interface:

bool MakeSequential()
bool MakeNonSequential()

Please note that the Syntax Help File about MakeNonSeqeuntial reads:

Makes the system non-sequential if it is not already. Note that any sequential data will be lost.

You can call those methods in your interactive extension by simply typing:


From the optical system interface you can either load a new blank file with:


If <save_if_needed> is True the current system will be saved before opening the new blank system. Or you can load an existing file with:

TheSystem.LoadFile(<lens_file>, <save_if_needed>)

In both cases, the current system will be closed. This is the same as if you were to press File..New or File..Open in the user interface.

Alternatively, you can open multiple OpticStudio applications (up to what your licence allows), allowing you to have at least two concurrent files at the same time in your interactive extension. This is a bit more complicated and I’d have to do some research before I can show an example. Therefore, if you don’t need it and can use the methods above, then you are fine.

As far as I’ve used OpticStudio, there has never been a way to “record” a macro. However, there’s a wealth of information about ZPL in the Help File (F1, and search for KEYWORDS, numeric functions, and string functions), and about ZOS-API in the Syntax Help File (Programming..ZOS-API Help..ZOS-API Syntax Help.

I hope this helps.

Take care,