Solves are functions which actively adjust specific values in an editor. Solves can be specified on curvatures, thicknesses, glasses, semi-diameters, conics, parameters, TCE values, and Extra Data Editor values. Solves are set by double clicking on the cell you wish to place the solve on.
There are many solves supplied with ZEMAX. For the list of available solve types, refer to the "Solves" chapter in the user manual. An arbitrary solve can be defined via the
ZEMAX Programming Language (ZPL). The solve window, accessed by double clicking on a parameter in the editor, has a "ZPL Macro" option (see below). Once the macro describing the solve has been created and placed in the {root}/ZEMAX/MACROS directory, the name of that macro can be entered to the right of the "Macro:" cell in the solve window.

As a simple example, we will require a non-sequential object to be 10 mm behind the end of another non-sequential object. This requires us to calculate the length of the previous object, and to use this to position the second object.
In the attached non-sequential sample file, the first object is a rectangular Compound Parabolic Concentrator object. This object has a maximum length defined as a parameter in the NSC Editor. If we could guarantee that the object would always be this maximum length, we could simply use a pick-up solve with an offset to position object 2. However, the real length may be smaller than the maximum length parameter, so we must calculate the real length and use this value. Also, as this is a rectangular CPC object, the real length may be different for the x and y slices: we must choose the smaller of the two. This is an ideal problem fo rthe macro solve!
The length "L" of the CPC is given by the formula in the manual (in the chapter on non-sequential components, section on non-sequential objects, sub-section on compound parabolic concentrator objects) as:

Since this is a Rectangular CPC object, there are two associated length values; X and Y. The smaller of the two lengths is then taken as the length of the CPC by ZEMAX, unless this length is larger than the "Length" parameter. In that case, the length is the value of the "Length" parameter. The macro should therefore calculate the X and Y length of the CPC object by using the formula above, pick the smaller of the two values, add 10mm offset and return that value to the Z Position parameter of the Rectangle object. If the smaller length between X and Y is still larger than the "Length" parameter value, then the macro should add 10mm offset to the "Length" parameter value and return this value instead.
The REC_CPC.ZPL macro is shown below.
The keyword SOLVERETURN is used to pass the desired value back to the NSC Editor.
Place the macro in the {zemaxroot}/MACROS folder and click "Macros > Refresh Macro List" in the main menu.
On the Z Position parameter of Rectangle object #2 place the following solve and click OK.

The Editor will show "Z" next to the parameter, indicating that ZPL solve has been placed on that parameter.

Toggle between the 2 configurations using the Ctrl-A keystroke; the Y angle parameter of the Rectangular CPC object will change betwee 20 and 40 degrees, hence changing the length of the object. The Z position value of object #2 will change automatically to always place this object 10mm behind the end of the CPC object.
