Skip to main content

We can use Python or Matlab Interactive Extension to execute Macro using ZPLM. Please take these steps

  1. Write a ZPLM code that can export JPG or BMP from a given window.                              GETSYSTEMDATA 1
    EXPORTJPG 1, "C:\test\JPG_file\3DLayout"
    EXPORTBMP 1, "C:\test\JPG_file\3DLayout"
    OPTRETURN 0                                                                                                                           You can read more about ExportJPG and EXPORTBMP in our help files: The Programming Tab > About the ZPL > KEYWORDS (about the zpl) > EXPORTJPG 
  2. Save the file as ZPL55 or ZPL”Any Number you like”. 
  3. Use this ZPLM in Merit Function Editor. In case if you like to know more about using ZPLM as Operand in Merit Function Operand. Please check this KBA: Optimization using a ZPL Macro: the ZPLM operand. Save this Merit Function as “ExportImage.MF” in folder Zemax LLC\Documents\Zemax\MeritFunction 

        4.Write Python or Matlab Program to run the ZPLM through Interactive Extension.                                    You can know more about this following this link How to run macro via ZOSAPI                                    Python code:                                                                                                                                                   file = r"C:\test\Double Gauss 28 degree.zmx"
         TheSystem.LoadFile(file, False)
         mf=r" ZemaxLLC\Documents\Zemax\MeritFunction\ExportImage.MF"
         TheMFE = TheSystem.MFE
         TheMFE.LoadMeritFunction(mf)
         TheMFE.CalculateMeritFunction()                                                                                                              

 

We can use a similar method to update all the windows in OpticStudio. So, if you find any functionality in ZPL but not in ZOS API. Then we can use this way to accessible the feature or functionality from API.  

Please comment below for functionality available in ZPL but not in ZOS API?

 

Thanks

Sahil


Hello, 

 

Is there now a function to save 3D layout without any work around ? 

 

The work around does not allow me to interactively change path and image name. 

I need to save 3D layout in different state and check if everything is file and that the ray airming is working correctly. 

 

I think 3D layout is the best to check that the implemted code is doing what is expected.


Reply