Skip to main content

Export Analysis, Graph and Layout JPG using ZOSAPI Interactive Extension Python and Matlab using ZPLM


Sahil
Forum|alt.badge.img+1

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()                                                                                                              

 

Did this topic help you find an answer to your question?

2 replies

Sahil
Forum|alt.badge.img+1
  • Author
  • Visible
  • 22 replies
  • September 6, 2022

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


  • Monochrome
  • 5 replies
  • November 16, 2023

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings