Skip to main content

A user asked why when using ZPL macro to save the Cross Section Row Coherent Irradiance data from Detector Viewer, the .txt file he got does not match the information displayed in the Text tab of the Detector Viewer. Instead of seeing a 2-column data of X position versus Irradiance, he kept seeing 3-column data displaying “Spatial Frequency, X and Y”



This is because in his code, the Configuration file is saved with the settings displayed in the Graph tab of the Detector Viewer, where the Cross Section Row is data value #4 in the “Show As:” dropdown list, (the index starts at 0). However, the GETTEXTFILE keyword is retrieving data from the Text tab of the Detector Viewer, where there isn’t a data value #4 in the “Show As:” dropdown list, so OpticStudio simply saves the data from the last available data value #3 which is the “Geometric MTF”.



In order to save the data for the Cross Section Row irradiance, you need to use MODIFYSETTINGS keyword to set this “Show As:” data value to data value #1 which then points to “Show As: Cross Section Row” in the Text tab of the Detector Viewer. A code snippet is shown below for your reference.



For i,1,3,1


z = 0.01*(i-2)


SETNSCPOSITION 1, 5, 3, z





Update ALL





a= NSDD(1,0,0,0) 


NSTR 1,2,0,0,0,0,0





OPENANALYSISWINDOW DVR,  


LOCKWINDOW i+2 





path1$ = 'C:\Users\hui.chen\Documents\Support related\Customer Files temp\'


config$ = path1$ + 'TestGetTextFile.CFG'


MODIFYSETTINGS config$, DVW_SHOW, 1


MODIFYSETTINGS config$, DVW_DATA, 1





FORMAT 1 INT


z$ = $str(i)


path2$ = 'C:\Users\hui.chen\Documents\Zemax\'


filename$ = path2$ + 'CrossSection' + z$ + '.txt' 


GETTEXTFILE filename$, DVR





MODIFYSETTINGS config$, DVW_SHOW, 4


MODIFYSETTINGS config$, DVW_DATA, 1


 


Next 

Hi,



I tried your code in zpl, but it is showing a code error always. Its showing



ERROR in MODIFYSETTINGS: Cannot open settings file.



Please share an attached .zmx file with custom ZPL code to save Detector viewer image and Detector Text data(pixel data).



 



Thank you


Hi Janmejaya,



This error usually appears when a wrong configuration file is provided. In Hui's code above, the configuration file is a .cfg file which matches the title of the ZMX file. This file may have a different name, or may not exist for you. In that latter case, you should use these lines instead:





data$ = $DATAPATH()

cfgfile$ = data$ + '\Configs\DVR.CFG'


You may find more explanation about how to use the configuration files in these forum threads:



ZPL: GETTEXTFILE with and w/o settingsfile · MyZemax



ZPL: Error in ModifySettings · MyZemax



access to cfg file · MyZemax



I hope this helps, but if you have any further questions, please let us know and we will be happy to help!



Best,


Csilla



 


Hi 



MODIFYSETTINGS modifies the settings file but doesn't create it. So you will need to first save the detector settings and then you can modify them. To save the settings, click on Save:





It will create a setting file under '\Zemax\Configs\DVR.CFG'. This file can be for example copied under a folder like my colleague did and then modified.



Do not hesitate if it is not clear.



Sandrine


Reply