Soon, we will launch a new and updated customer portal, which is an important step toward providing our customers with one place to learn, interact, and get help.
Learn more.

How to Model a Phantom Lens

This article describes how to modeled a turreted lens system using the multi-configuration capabilities of Zemax OpticStudio. A number of IGNR operands are necessary for ignoring the turreted lens in one of the configurations, and are added with a ZPL macro.
Sanjay Gangadhara
Frequently Asked Questions


In some optical systems, a set of the components may be mounted on a turret. The turret is used to rotate those components in and out of the beam path, allowing the system to be used for different applications.

Rather than modeling the system with and without the turreted lens in separate designs, such a system can be modeled in a single file using the multi-configuration capabilities of Zemax OpticStudio. In one configuration, the turreted lens is included in the system, and in another configuration the turreted lens is excluded.

Lenses may be included or excluded from a system using the “Ignore This Surface” flag:


The multi-configuration operand which can be used to turn this flag on or off is IGNR.

For systems with many components in the turreted lens, it can be tedious to insert a corresponding number of IGNR operands in the Multi-Configuration Editor (MCE). However, when faced with a tedious task, the best option is to use a ZPL macro! The macro “Multiple IGNR.ZPL” - provided in the article attachments - can be used to insert a number of IGNR operands in the MCE, and to set the “Ignore This Surface” flag on the desired surfaces.

Description of the macro

In the first part of the macro, we determine the configuration in which the turreted lens should be ignored. If the nominal system only contains a single configuration, then a new configuration is added to the system, and it is in that 2nd configuration that the turreted lens is ignored. If the nominal system contains more than one configuration, the user can specify whether the turreted lens should be ignored in one of the existing configurations, or in a new one:

x = NCON()

in_flag = 0

IF (x == 1)

nbsp;  conf_num = 2


in_flag = 1


INPUT "Which configuration should have surfaces ignored?", y

IF (y <= 0)

PRINT "Not a valid configuration number. Exiting program."



IF (y > x)

conf_num = x + 1


in_flag = 1


conf_num = y



Note: Comment lines have excluded from the copy of the macro shown above, and will be for those portions of the macro shown below. This is done for compactness. Full comments are provided explicitly in the macro.

In the next section of the macro, the user is asked to input the range of surfaces corresponding to the turreted lens. This range must be continuous; the turreted lens cannot consist of an intermittent range of surfaces. If more than one turreted lens is present in the system, the macro can simply be run multiple times. Error checks are then used to ensure that the user inputs are valid (i.e. that the surface range corresponds to surfaces actually defined in the system, and that the last surface in the range comes after the first one):

x = NSUR()

INPUT "What is the start surface number?", surf_start

IF ((surf_start <= 0) | (surf_start >= x))

PRINT "Not a valid starting surface. Exiting program."



INPUT "What is the end surface number?", surf_end

IF ((surf_end <= 0) | (surf_end >= x) | (surf_end <= surf_start))

PRINT "Not a valid end surface. Exiting program."



n_surface = surf_end - surf_start + 1

The next section of the macro uses the INSERTMCO keyword to insert rows into the MCE, where the IGNR operands will be placed:

z = MCON(0,0,0)

row_start = z + 1

row_end = z + n_surface

FOR i, row_start, row_end, 1



The IGNR operands are then added to the MCE in the newly defined rows using the SETMCOPERAND keyword:

n = 0

FOR i, row_start, row_end, 1

surf_set = surf_start + n


SETMCOPERAND i, 0, surf_set, 1

n = n + 1


The IGNR values for the turreted lens are then set to “1” in the configuration in which the turreted lens will be rotated out of the beam path:

FOR i, row_start, row_end, 1

SETMCOPERAND i, conf_num, 1, 0


Finally, if (and only if) a new configuration was added to the system to allow for control of the turreted lens, then values for any other multi-configuration operands which were present prior to the addition of the IGNR operands are copied into those corresponding operands for the new configuration. Those values are always copied over from configuration 1 of the system:

IF (in_flag == 1)

FOR i, 1, z, 1

x = MCOP(i,1)

SETMCOPERAND i, conf_num, x, 0



More details on the INSERTMCO and SETMCOPERAND keywords, as well as the MCON and MCOP functions, may be found in The Programming Tab section of the help files.

An example

For a simple example, open the file Double Gauss 28 degree field.zmx, located in the folder ...\Documents\Zemax\Samples\Sequential\Objectives. We will use the attached macro to place the second triplet on a turret.

First, add a surface to this system, right before the image plane (new surface 12). For the thickness of this surface, use a position solve:


This solve will place the image plane at a fixed distance from the stop surface, independent of the presence of the second triplet. As the new surface is simply a dummy surface used for positioning, we will choose not to draw it:


Now, we are ready to place the second triplet on a turret. To do so, download the macro from this article, and place the file in the directory ...\Documents\Zemax\Macros (or in whatever directory you have specified as the ZPL directory under the Setup > Project Preferences > Folder menu). Then, run the macro in the double gauss file.

Since this is a single configuration file, the macro will add a second configuration to the system, and ignore the turreted lens in that configuration. The first surface should be 7:


and the end surface should be 11:


If we open the Multi-Configuration Editor, we’ll see:


We can see the difference in performance of this system with and without the turreted lens by comparing the results for configurations 1 and 2, e.g. the 3D Layout Plot (Set Configuration: All; Offset Y: -65; Hide Lens Edges; Hide X Bars): 


and the Spot Diagram: