Skip to main content

Hi, 

 

I am trying to run non-sequential sequence in a loop, for which I change a parameter and save the detector data for each loop. The text tab should allow me to export the irradiance data at each coordinate, but I am a little uncertain how I can grab detector 1 and 2, then save the data as text files as for example data_d1_01 and data_d2_01, data_d1_02 and data_d2_02,..etc. Any suggestions appreciated. My experience with ZPL is limited. 

My attempt: 

update ALL
FILENAME$ = "data_xtilt"+ $STR(xtilt) + "_tiltY_" + $STR(ytilt) + ".TXT"
savewindow 1, H:\_work\ZEMAX\+FILENAME$
savewindow 2, H:\_work\ZEMAX\+FILENAME$

This got an error “ERROR in SAVEWINDOW: Window 1 does not support text”

A few things I would change about your code:

  • If your xtilt and ytilt are integer whole numbers, I would use FORMAT .0 to make sure the $STR() only prints an integer.  If these are not integer whole numbers, I would not use them in the filename since they will add extra periods or commas which could lead to invalid filenames
  • If possible, I would avoid saving to an external drive.  Although the H:\ drive might be mounted to the same CPU, I’ve see issues with connecting to external or network drives
  • I would make sure the filename isn’t too long.  OpticStudio tends to “clip” strings at 255 characters so if your filename is too long, it won’t save
  • You need to have your actual filename as a string literal, so you need to use double quotes.

The following should work:

update ALL
FORMAT .0
FILENAME$ = "data_xtilt"+ $STR(xtilt) + "_tiltY_" + $STR(ytilt) + ".TXT"
savewindow 1, "C:\_work\ZEMAX\" + FILENAME$
savewindow 2, "C:\_work\ZEMAX\" + FILENAME$ ! note this will overwrite WIN 1

 


Reply