I want to create zpl macro that print TFR (throogh focus MTF) data to text file. In order to get relevant information I need to change the settings.
I tried to do this by 'MODIFYSETTINGS' but then I got error massage that said 'cannot open setting file'.
I did not find any explanation in Zemax manual where this setting file located and I can create it such that it can be open. I would like if you can give me some information about this file type and how I can access into it.
image of ZPL file:
Thanks for your follow up questions here!
For the settingsfilename, it must include the full path, name, and extension for the file to be modified.
Regarding the error message, this means that the file doesn’t exist or it’s occupied by other processes. The second condition may occur if you have another process/software that is trying to modify the same CFG file.
You could check the followings:
Regarding your other issue, that the macro did not modify the settings, this is probably due to the syntax, please see below:
If you would like to change multiple settings, you need to do this in separate lines. Instead of the single line used in your first comment, you will need 3 lines to change the sampling, the delta focus, and then the frequency, one after the other:
MODIFYSETTINGS settingsfilename$, TFM_SAMP, 5
MODIFYSETTINGS settingsfilename$, TFM_DELTAFOC, 1
MODIFYSETTINGS settingsfilename$, TFM_FREQ, 100
I hope this helps!
Thanks for the detailed answer.
I tried to work as you suggested (i.e. settingsfilename$ = FileNameStringsBase$ + configfile$) but I got a massage : 'cannot open settings file'.
The macro ran only when I defined: settingsfilename$ = 'TFM.CFG ' ,
but then the settings was not modified- I got TFR data of the saved settings.
I think that somethong is missing... maybe the way of connecting the configuration file with the lens file name and the configuration file specified to the chosen analysis feature.
You are right, that the MODIFYSETTINGS keywords can be used to change the settings via the Zemax Programming Language (ZPL). However, it is important to understand that this keyword does not make direct changes to the settings of an open analysis window of a specific lens file. Instead, MODIFYSETTINGS makes changes to the configuration files of the analysis features or graphic windows. Each analysis feature and graphic window has its own settings and its own configuration file, and these analysis-specific .CFG files should be used instead of the configuration file of the lens file. Specifically, in your case, to change the settings of the FFT Through Focus MTF analysis, the TFM.CFG file should be used.
In order to make changes, you should follow the procedure below:
When changing the settings within the macro language, you have modify the analysis-specific configuration file, and not the lens configuration file.
Please note, that in order to ensure that the analysis-specific configuration files located in the main Zemax directory are not perturbed, you may copy and paste the necessary configuration files into a temporary folder, and then use these files in the macro. You may of course also choose to modify the configuration files located in the main Zemax directory with the macro.
So to sum up, in your code you should modify the TFM.CFG file to set up the desired settings for the detector viewer:
configfile$ = 'TFM.CFG'
settingsfilename$ = FileNameStringsBase$ + configfile$
You may find a list below, showing which parameters can be changed for the FFT Through Focus MTF analysis by MODIFYSETTINGS, together with the type codes of these parameters:
Please let us know if you have any further questions!