delete solves in Zemax using ZPL

  • 7 September 2022
  • 1 reply

Hi Zemax Community, 

I have a quick question, is there a command for deleting all solves in the lens file using ZPL? I wasn’t able to find any resources. Would appreciate if someone can point me to the right resources or let me know what command I should use. Thanks!

[Mod note: moved to more appropriate forum for ZPL-related discussions.] 


Best answer by David.Nguyen 8 September 2022, 13:09

View original

1 reply

Userlevel 7
Badge +2

Hi zemax_user,


In general, removing a solve in ZPL can be done by actually applying the Fixed solve type using the keyword SOLVETYPE. The solve type code is a two letter code which identifies what the solve type is. For Fixed type it ends with the letter F. If you wanted to remove the solve on the Thickness you’d use the code TF with the SOLVETYPE keyword like so:


Where surface is an integer starting from 0, which refers to the surface number where the solve is located. The other type codes can be found in the Help File (F1) under: The Programming Tab > About the ZPL > KEYWORDS (about the zpl) > SOLVETYPE.

I don’t think that there’s a single Keyword that will remove all the solves from your file. One solution could be to loop over the surfaces and remove all the possible solves in each line of the Lens Data Editor. Perhaps a better solution, if you are at the benefit of a professional or premium licence, would be to leverage the Tolerance..Design Lockdown tool. However, I don’t think it can be used through ZPL. You’d have to use the ZOS-API for that, and one limitation is that it would change your Aperture Type to Float By Stop Size. Here’s a sample code in Python:

design_lkd = TheSystem.Tools.OpenDesignLockdown()

design_lkd.ExcludePickups = False
design_lkd.UsePrecisionRounding = False
design_lkd.FixModelGlass = False
design_lkd.ConvertSDToMaxApertures = False


And here are the before/after of the Lens Data Editor:

As you can see, the tool fixed the apertures of Surface 0 and 1 (the STOP surface), indicated by the letter U. And the Aperture Type is now Flot By Stop Size. Obviously, you could write a piece of code that would first query the Aperture Type, apply the Design Lockdown, and restore the Aperture Type. Let me know if that makes sense or if you need help programming that.

Take care,