Analysis Features

Should I use the ZOS-API or ZPL?

Relating to: Programming ZOS

Both ZPL and the ZOS-API are powerful tools for automating optical design with OpticStudio. Sometimes it can be difficult to decide which is better for a given application. ZPL is a language developed by Zemax to allow scripting within OpticStudio. The ZOS-API allows a user to automate OpticStudio using several mainstream coding languages, such as C#, C++, Python, MATLAB, and Mathematica.

ZPL in general is much more limited than the ZOS-API, but it is simpler to use. ZPL does not allow for complete control of everything you can do with the OS GUI, whereas the ZOS-API exposes many more controls in a manner closely matching GUI interaction. It is important to note that the drawback with the ZOS-API is that getting started is a bit more involved than ZPL. If you need to do something quick and simple, ZPL is a good choice. ZPL is also required for things like custom Solves or Merit Function operands.

In general, the ZOS-API has two operating modes: a standalone application or a user extension. A stand-alone application will run OpticStudio in the background and retrieve analysis data as needed. The extension will control an open OpticStudio window so that the user can run the ZOS-API in tandem to changes they make in the GUI. The user extension is the closer option to a ZPL script in the sense that it requires an open OS GUI.

Finally, the ZOS-API will give the user access to more resources. Since it is based on the .NET framework and standard coding languages, it allows the user to call other external libraries to help in building an application. This can open up additional numeric or plotting libraries, for instance. ZPL does have built-in functions to work with numbers and do limited plotting— just not to the extent of the larger code bases offered by other languages.  

For more information on ZPL, please see the Help File: The Programming Tab > About the ZPL.

To get started with the ZOS-API, please see this link: Getting Started with ZOS-API – Zemax.