- Home
- Programming ZEMAX
- ZPL
- How to Automate Keyboard and Mouse Actions with ZPL
How to Automate Keyboard and Mouse Actions with ZPL
Executing the Macro and Evaluating the Results
Once the macro has been constructed, you may save the macro using any desired file name. However, the extension of the macro must be .ZPL. For the current example, “Twyman-Green.ZPL” is a suitable file name.
Note that ZPL macros must be saved into your ZEMAX > Macros directory or any sub-folder so that they may be called from within ZEMAX. Or, the default folder used for macros can be set under the File > Preferences > Directories tab. Save the current macro with the desired filename in the appropriate directory.
Macros may be executed one of two ways. If you select “Macros” from the main ZEMAX menu, all of the available macros are listed in alphabetical order from the pull down menu that appears. If your macro does not appear on the list, try refreshing the macro list by selecting “Refresh Macro List.” 
If the macro still does not exist after refreshing the list, double check the directory and filename of your recently created macro.
If you simply select the macro from the list, ZEMAX will automatically execute the macro. Or, as was described earlier, you may select “Edit/Run ZPL Macros” to activate the ZEMAX Programming Language dialog. Once the desired macro is selected, you may execute or edit the macro via the available buttons on the bottom of the dialog.
Execute the Twyman Green macro from within ZEMAX. Be aware that the macro may take a few minutes to complete due to the number of non-sequential ray traces. However, the point here is that this automation may be performed on a much larger scale, enabling you to use your time much more valuably while ZEMAX continues to “number-crunch.”
After the macro is complete, view the directory to which the files were saved; a total of five metafiles should have been created. Each of the images can be used to perform a qualitative analysis as to how the interference fringes were affected by the tilt of the test surface in the Twyman Green Interferometer.
Four of the five files are shown below, excluding the nominal case in which the tilt of the test plate was zero.


TG - Tilt About X By_0.0250DEG.WMF TG - Tilt About X By_0.0500DEG.WMF 

TG - Tilt About X By_0.0750DEG.WMF TG - Tilt About X By_0.1000DEG.WMF
