How To Update and Change the Settings of a Graphic Window from...


This article describes how to change the settings of a graphic window via the MODIFYSETTINGS ZPL keyword. 

Authored By: Dan Hill

Introduction

Each analysis feature and graphic window has its own settings.  We may change them as we desire, and also change the defaults so that the next time we open the same analysis feature, a certain combination of saved settings are used.  Sometimes, it is desirable to observe how the results of an analysis change as a function of a setting (field number, polarized or unpolarized for example).  This may be done manually, or we can automate the process via the Zemax macro language, or ZPL.

To make changes to the settings of an analysis feature via the macro language, the MODIFYSETTINGS keyword is required.  It is important to understand that this keyword does not make direct changes to the settings of an open analysis window.  Instead, MODIFYSETTINGS makes changes to the settings files, also known as the configuration (.CFG) files.  For details on what the configuration files are, click here.

So, if the MODIFYSETTINGS keyword does not make direct changes to an open analysis window, how can we update a graphic window to reflect the changes made to the configuration file?  This requires a little “trick” in Zemax, which this article describes.  Read on!



Setting up the File

To demonstrate this capability, we will start with the “Double Gauss 28 degree field.zmx” file located in your Zemax>Samples>Sequential>Objectives folder.

Open this file and open a Shaded Model plot (Analysis > Layout > Shaded Model).  In the settings, click the “Reset” button (in case you have previously saved settings which are not the Zemax defaults), and then change the Rotation X and Rotation Y values to 10 and 10 degrees, respectively.

Shaded Model Settings

Once the values have been set, save the settings by clicking the “Save” button.

When the “Save” button is chosen, Zemax creates a configuration file with the lens file name (in this case, the file is “Double Gauss 28 degree field.CFG”) as well as a configuration file specific to the chosen analysis feature (for the shaded model, this file is called LSH.CFG).  The LSH.CFG file exists within the main Zemax directory.  The lens specific configuration file is saved in the same path as the currently opened lens file.

When changing the settings within the macro language, you must modify the analysis-specific configuration file, e.g. LSH.CFG, and not the lens configuration file.

Note: 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, as illustrated in example provided in the next section.



Writing and Executing the Macro

In this example, let’s change the Z rotation parameter of the Shaded Model settings within the macro language.  For each incremental change in Z, we can export a screen shot of the updated window.

The syntax for the MODIFYSETTINGS keyword is as follows:

MODIFYSETTINGS settingsfilename, type, value

The settingsfilename is the full path, name and extension of the configuration file to be modified.

The type argument is a text mnemonic that indicates which setting within the file is to be modified.  See a complete list of available type codes in the Zemax User’s Guide.  For the Shaded Model Z rotation, MODIFYSETTINGS keyword is SHA_ROTZ. 

To increment the z rotation from 0 to 360 degrees, we will create a simple FOR loop:

Shaded Model Z Rotation Macro Syntax

After the MODIFYSETTINGS command within the FOR loop, the lens is reloaded without using the session file (see the docs on the LOADLENS keyword for details).  The Shaded Model window is then updated.  By reloading the lens file without the session file, the window is updated using the settings in our configuration file instead of the session file.

In this particular example, a total of 24 BMP files are created, each of which shows an incremental rotation about z.  As a result, we can easily create an animation using these saved files.  To learn more, click here!



Summary and References

The MODIFYSETTINGS keyword in the macro language can be used to change data within the settings files, or the configuration files in Zemax.  Normally, this is used in conjunction with the GETTEXTFILE keyword, as one of its inputs is the desired configuration file.

For graphic type windows, a little trick may be used.  This trick involves reloading the same lens file after making any changes to the analysis specific configuration file located in the main Zemax directory (for example, LSH.CFG for the Shaded Model).  If the lens is loaded without a session file, then the settings found in the analysis’ configuration file are used to update the desired window number.

REFERENCES

Zemax Optical Design Program User’s Guide, Zemax Development Corporation





Attachments





© All Rights Reserved.