Record GUI interaction as ZPL commands?

  • 20 September 2023
  • 2 replies

Userlevel 3

I was helping a colleague with ZPL the other day. He wanted to know how to set a field as a variable and then constrain it. Additionally, he wanted to do this through a ZPL.

The first part is easy enough. My approach was to expose the field as a variable through the multi-configuration editor using “YFIE”, declaring the solve as “Variable” and then constraining it in the merit function editor with “MCOL”, “MCOG”, or “MCOV”.

For the ZPL portion, I wrote a small script for him demonstrating how to assign a variable in the MCE with ZPL.

! INSERTMCO, 1 # insert a row into the mce.
SETMCOPERAND 1, 0, "YFIE", 0 # changes the operand to "YFIE"
SETMCOPERAND 1, 0, 1, 1 # assigns YFIE to field no. 1
SETMCOPERAND 1, 1, 15, 0 # changes the value of row 1 config 1 to 15
SETMCOPERAND 1, 1, 1, 3 # changes the solve type to "V"

This made me think that it would be useful if there were a way to record GUI interactions as lines in a ZPL. For example, I could turn on the proposed feature and a text window would open in the background. When I click on row 1 of the multi-configuration editor and press “insert” a line would appear in the text editor “INSERTMCO, 1”. Once I have completed my task, I would turn off the feature, review the text file and could use it as reference for writing my own ZPL.

I realize that this is easy to conceptualize but perhaps difficult to implement. I didn’t see anything in the help file that resembled this idea. It there a way to do this with Zemax currently? If not, it would be useful as a feature request.


Best answer by David.Nguyen 21 September 2023, 12:49

View original

2 replies

Userlevel 7
Badge +2

I’m quite sure OpticStudio doesn’t have this feature, and I like the idea.

I know that ImageJ (or Fiji) has a macro language as well, and I’ve used their macro recorder countless times, see this as an example.

I imagine it must not be easy to implement though.

Take care,




Userlevel 3

Hi @David.Nguyen ,

Thank you for the reply. The comparison to ImageJ is apropos and the best example that I could think of to offer the Zemax team.

For reference, here is a link to ImageJ’s recorder function,

ImageJ Recorder