Optics

Optics

Topics related to Speos.

To create ZPL for the non-sequential calculations.

    • Anonymous 1996
      Subscriber

      I want to generate detector responses for varying Z-positions of object 4. I know I can use ZPL macros to create various variables and perform ray tracing. Can anyone tell me exactly how to do that here? Additionally, in these scenarios, what should be implemented in ZPL and what in the ZOS-API? If ZOS-API is more convenient for these scenarios, can you guide me on how to create a function to vary the Z-position and plot detector responses for given values?

      Thank you for your help.

      Regards,

      Navaneeth

       

    • Ethan Keeler
      Ansys Employee

       

       

      Hi Navaneeth,

      Thanks for your question! As you pointed out, there are two ways to create automated routines in OpticStudio, using ZPL or the ZOS-API. Which to chose depends on a few factors. ZPL is much simpler and easier to get started with; however, it is more limited in functionality. On the other hand, if you are comfortable with programming using Python, MATLAB, C++, C#, etc., then the ZOS-API might be a good route because in the long run it will give you more control over OpticStudio. Using the ZOS-API also lets you more easily manipulate and process the data using third party libraries (e.g. MATLAB). 

      To get started with ZPL: Introduction to Zemax Programming Language (ZPL) – Knowledgebase
      To get started with the ZOS-API: Understanding the basics of ZOS-API structure – Knowledgebase (zemax.com)

      As for your specific question, I’ll show you the basics of both methods.

      ZPL: You will want to use SETNSCPOSITION to change the Z location (more information in the Help File, The Programming Tab » About the ZPL » KEYWORDS (about the zpl) » SETNSCPOSITION (keywords)), and as an example: 

      SETNSCPOSITION 1, 4, 3, 115

      To get the detector data, you will want to use OPENANALYSISWINDOW and then either EXPORTJPG (to get an image) or GETTEXTFILE (to get the data in text form). You can find a good example of this here: Saving detector series data / img with ZPL | Zemax Community

      ZOS-API: 

      To change the Z-postion, in the ZOS-API, you would call something like this (for more information on the command, check out the ZOS-API Help File):

      TheSystem.NCE.GetObjectAt(4).ZPosition = 115;

      For the detector data, this is a little more involved as I mentioned, but there is a detailed explanation here: Methods for extracting detector data through the API | Zemax Community.

Viewing 1 reply thread
  • The topic ‘To create ZPL for the non-sequential calculations.’ is closed to new replies.