Skip to main content

I have a number of optical subcomponents that can be combined into different systems (think a variety of objectives and tube lenses). Currently if I were to design a new objective and I wanted to see how it performed with all the different tube lenses, I would have to copy and paste it into each tube lens file.

I’d like a way to combine these programmatically. I’m imagining two drop down menus, one for objective and one for tube lens, and they’d refer to a library of designs. I’d pick each component and they’d load into one Zemax file, from which I could then calculate mag, MTF, lateral color, etc.

What’s the best way to accomplish this? I have some ZPL and Matlab experience and no ZOS-API experience, but I do have several teammates with experience in Matlab, Python, and C# who I can call upon for assistance (and I’ve been meaning to learn Python and C# anyhow).

Does anyone have any suggestions for where I should start attempting this project?

Hi Karen,

 

I typically only use ZPL for basic repetitive tasks. When the intended use is more complex, I automatically switch to the ZOS-API.

In your case, you seem to require a user-interface (UI), which is only possible with the ZOS-API and that would be my recommendation.

As far as programming languages go, I would start a prototype with MATLAB or Python (both are kind of equivalent), whichever you are most comfortable with. Once you have it running, I would switch to a compiled programing language such as C++ or C#. C# might be easier to interpret and learn in this case. The reason behind the change to a compiled programing language is because they are much faster to execute. So, if you need a program to go through a list of file and combine them together, you might find that both MATLAB and Python are quite slow.

Although this is not my specialty, I had done a user analysis with a custom UI in this thread with the help of @Sandrine Auriol . Feel free to have a look at it (its in C#), it has a couple of drop-down menus to illustrate what you could do.

I hope this helps.

Take care,

 

David

 


David is correct that ZPL can’t create a UI with drop-down picklists and the like, but it seems to me that what you want to do is pretty straightforward to do in ZPL, and that you may take more time crafting a UI than in actually doing the work you want to do :thinking:

I’d suggest that a good naming convention, such as File_01, File_02 etc, should be used to make it easy to create filenames inside a For/Next loop. Once you’ve created your file, OpenAnalysisWindow will create any analysis you need, or you could load a .MF merit function file to read out specific data. A Report window is also useful to create a standard page for comparing different  lens designs:

 

That’s how we created all the graphics used in the Zebase user manual, for example.

But by all means, if you want something that behaves more like a front-end program, with picklists and so on, ZOS-API will do exactly that.

 


Hi Karen,

David and Mark have thrown up some great ideas. I also wanted to chime in with another option. 

Within the OpticStudio UI, you are able to generate your own Lens Catalog with the Make Private Catalog button under the Libraries tab. This tool will convert a folder full of ZMX or ZOS file to a stock lens catalog file. I think you could probably take this approach:

  1. Create a folder which has each of your subcomponents
  2. Use the Make Private Catalog button to convert that folder into a Lens Catalog
  3. Use the API to either load or insert the lenses in the same way you would with the standard Lens Catalogs. In the UI, that looks like this:

 

As it sounds like the API might be the ideal solution for you, I recommend starting with our guided tutorials here: Getting Started with ZOS-API – Zemax.


Oooohhhh, good one @Allie !


Reply