Where is the detail explanation of MODIFYSETTINGS key word "Tfg"?

  • 8 September 2023
  • 7 replies

Hi, I’m trying to develop a ZPL macro that can get the Through Focus Geometic MTF which modifysettings key word is “Tfg”. But I’m not able to find detail explanation of “Tfg” in UserManual.PDF. In case of “Tfm”,  I  know the Modifysettings of “Tfm” is supported. 

I was able to run the ZPL code like below.

    MODIFYSETTINGS tfmcfg$, TFM_SAMP, calc_tfm_samp

But the ZPL code include “Tfg” like below has errored.

MODIFYSETTINGS tfgcfg$, TFG_SAMP, calc_tfg_samp

ERROR in MODIFYSETTINGS: Incorrect version number in settings file.

Please let me know whether “Tfg” code is supported or not?

Keiya Yoshida



Best answer by David.Nguyen 11 September 2023, 14:47

View original

7 replies

Userlevel 7
Badge +2

Hi @Keiya.Yoshida,


If you didn’t find the settings list in the Help File for MODIFYSETTINGS, then it is likely that they haven’t been implement (thus not supported).

For your information, the Through Focus Geometric MTF is fully implemented in the ZOS-API though. Meaning you can adjust the settings directly in the ZOS-API and the analysis will return a data series.

There’s a thorough ZOS-API example to Retrive Data from FFT MTF (example 04) in the Programming..ZOS-API Help..ZOS-API Syntax Help, and here’s a minimal example to edit the settings of the Through Focus Geometric MTF in Python:

# Open new Geometric Through Focus MTF analysis
geo_mtf = TheSystem.Analyses.New_GeometricThroughFocusMtf()

# Retrieve settings
geo_mtf_settings = geo_mtf.GetSettings().__implementation__

# Edit settings (list of available settings in the Syntax Help File)
geo_mtf_settings.UsePolarization = True

# Apply settings and run analysis

# Close analysis

Down the line, there’s also a Python module called ZOSPy, which supplements the ZOS-API that you might want to check out in the future if you like the ZOS-API (it helps with running the ZOS-API in a more “Pythonic” way).

Hope this helps, and take care,



Hi, David

Thank you for your reply!

It means that I have no choise but to use ZOS-API instead of using ZPL macro.

And it will be a great help of showing me your sample code.

I will use it as a reference.

Keiya Yoshida

Userlevel 7
Badge +2

Hi @Keiya.Yoshida,


There might still be a way to use ZPL, but it could be cumbersome depending what you want to do. I’ll give you the recipe and an example just in case:

  1. Open a Geometric Through Focus MTF manually
  2. Adjust the settings to what you need
  3. Save the settings file by pressing the Save button (this creates a file that has the same name as your lens file, but with *.CFG as the extension, and puts it in the same folder)
  4. Rename this file to something like “<lens_name>_CONFIG00.CFG”
  5. Change the settings as needed
  6. Save the settings file
  7. Rename this file to something like “<lens_name>_CONFIG01.CFG”
  8. Repeat as many times as needed (this is the cumbersome bit)
  9. In your macro, use COPYFILE to copy the different configuration files into the default one before calling the Geometric Throught Focus MTF (more detail in my code below)

And this is an example code. I have made a submacro to remove NN characters on the right of a string (to remove the extension of a file for example). This is the submacro:

# Retrieve input string
input$ = $CALLSTR(1)

# Retrieve input number of
# characters to be removed
nn = CALD(1)

# Input string length
length = SLEN(input$)

# Return input string
# without its <nn> right-most
# characters
CALLSETSTR 1, $LEFTSTRING(input$, length-nn)

And then this is my example, which uses the submacro above:

# This script assumes you have < 101
# configuration files with a name defined
# as <prefix><XX>.CFG where <XX> is a
# two digit integer starting at 00.

# Lens filepath (without filename)
lens_path$ = $PATHNAME()

# Lens filename
lens_file$ = $FILENAME()

# Remove filename extension (4 characters
# on the right)
CALLSETSTR 1, lens_file$
CALLMACRO rm_n_chars_on_the_right.ZPL
lens_file$ = $CALLSTR(1)

# Build configuration filepath
config$ = lens_path$ + "\" + lens_file$ + ".CFG"

# Print configuration filepath
PRINT "> Configuration filepath: "
PRINT "> " + config$ + $NEWLINE() + ">"

# Number of custom configuration files
config_num = 2

# Custom configuration file prefix
prefix$ = "LENS_CONFIG"

# Adjust printing format for $STR()
FORMAT "%#02i" LIT

# Print loop starting comment
PRINT "> Applying following configuration file:"

# Loop over the configuration files
FOR ii, 0, config_num-1, 1
# Retrieve new config file
new_config$ = lens_path$ + "\" + prefix$ + $STR(ii) + ".CFG"

# Print current configuration file to be applied
PRINT "> " + $STR(ii) + ". " + new_config$

# Copy new config file
COPYFILE new_config$, config$

# Run Through Focus Geometric MTF

For this code to work, you need to have a folder like so:

Where LENS.ZOS is your lens file, and LENS_CONFIGXX.CFG are the configuration files that you saved previously as documented above.

The ZPL code will take every configuration file named LENS_CONFIGXX.CFG and copy it in this folder as LENS.CFG sequentially. After each copy, the code creates a Geometric Through Focus MTF which uses LENS.CFG for its settings. The output looks like so:

And you should also have your Geometric Through Focus MTF open with the corresponding settings. I’m attaching the macros and all my files so you can reproduce the results yourself.

Last thing I should mention about the ZOS-API. Be wary of this peculiarity if you are using Python:

Good luck and take care,



Userlevel 7
Badge +2

One more remark, you could actually use:

# Run Through Focus Geometric MTF
OPENANALYSISWINDOW "tfg", new_config$

Instead of COPYFILE. I’ll write a short post about this method and I’ll link to it here once done.

Take care,


Userlevel 7
Badge +2

Here’s the new thread:


Hi, David

Thank you for your kinder advice!! I may have been able to unuderstand. If I want to code that macro by ZPL, you mean that I must use command “OPENANALYSISWINDOW” thought I can’t code it by using command “GETTEXTFILE”. Actually, the ZPL code you attached is a little bit too long and cumbersome! If I have enoght time to revise my ZPL code, I just want to try it.But at firtst, I will try it by using ZOS-API. Thank you.

Keiya Yoshida

Userlevel 7
Badge +2

Good luck @Keiya.Yoshida, I think you have the right approach. I just wanted to suggest the ZPL approach in case you absolutely didn’t want to use the ZOS-API.

Take care,