ZEMAX supports the ability to perform Boolean operations on volume NSC objects. This feature allows operations such as adding objects together, subtracting one object from another, or defining an object as the intersection volume of two objects. The resulting trimmed object may have properties assigned to each resulting face independently.
This article discusses how to use the Boolean object and the Combine Objects Tool.
This article is also available in Japanese.
This article is also available in Japanese.
ZEMAX supports the ability to perform Boolean operations on volume NSC objects. This feature allows operations such as adding objects together, subtracting one object from another, or defining an object as the intersection volume of two objects. The resulting trimmed object may have thin-film coating, scattering and diffraction properties assigned to each resulting face independently.
This article discusses how to use the Boolean object and the Combine Objects Tool.

The Boolean object can take up to 10 "parent" objects, but in this case we are using only two objects. The Boolean operations we can perform on these objects are as follows:
+ Combines the two objects together (logical A OR B).
- Subtracts the second object from the first (logical A AND NOT B).
& Computes the intersection of the two objects (logical A AND B).
^ Yields the portion of the object that is part of one or the other, but not both objects (logical A XOR B).
$ Subtracts the first object from the second (logical NOT A AND B).
You can also use combinations of these. The Boolean operations to be performed are entered in the Comment field of the Boolean object:

So this yields a volume equal to object A OR object B

Here objects A and B are shown at the bottom, and the Boolean object A+B is directly above. Note that as the parent objects are parametric, the Boolean object is too: if the radius of either sphere is changed, the Boolean object will update too. The parent objects can be made of any glass: the parent object glass is ignored, and glass or gradient index properties are added to the Boolean object itself.
Surface properties of the Boolean object are inherited from the parents. The sphere object consists of a single face per object, and so the Boolean a+b of these objects consists of two faces:

Both of these faces are inherited from the parent object:
And so if the object 1 sphere has an AR (MgF2) coating on it, then so does face 0 of the Boolean object:

Note also that if you do not want the parent objects to interact with rays, you can select "Rays Ignore This Object" under the Type tab of the object properties, and if you do not want to object to be drawn on screen, you can use the "Do Not Draw Object" switch on the Draw tab of the object properties
![]() |
![]() |

A AND B: Syntax A&B

Its easy to get AND and OR mixed up. Remember that OR will give you the volume occupied by either object, while AND gives you the volume occupied by both objects.
A XOR B: Syntax a^b

This gives you the volume contained by either but not both objects. In this case, if the Boolean object was made of glass, then there is no glass in the region of overlap between the two parent objects.
A AND NOT B: Syntax a-b

This is effectively a subtraction operation, in which any overlap of objects A and B is removed from object A
NOT A AND B: Syntax a$b

The volume produced is equivalent to B AND NOT A, b-a, but there is a subtle difference: the Boolean object has the same coordinate system as whatever object is listed first. So a$b will yield an object positioned relative to the same point in space as object a, and b-a will produce the same volume positioned relative to the same point in space as object b.
Up to ten objects may be the parents of a single Boolean object, and Boolean objects may also be the parent objects of other Boolean objects. This allows objects of any complexity to be made. Parent objects must be defined prior to the Boolean object in the editor. All operations are carried out in left-to-right order.
Here, for example, is a more complex Boolean object. It is available in {zemaxroot}/samples/non-sequential/boolean/lens mount.zmx:

This object is made with the string a-b-c-d, and it allows a simple, but fully parametric lens mount object to be made easily.

These obejcts are set to "Do Not Draw This Object" in the file, and so they will not appear in the layouts unless you change this setting. The Boolean object is formed by taking the intersection of these objects, A AND B:



So, this face is set to be reflective, with 40% probability of a ray being scattered by a Lambertian scattering function. No coating is defined, and so ZEMAX assumes the face has the reflectivity of bare Aluminum. It is also set to diffract 40% of the unscattered light into order -1, 40% into order +1, and 20% into the zero order. All these properties are inherited by the Boolean object:

Rays are reflected, diffracted and scattered by the Boolean object. Rays that land outside the aperture defined by the extruded object are transmitted normally, and you can see the C-shaped shadow cast by the Boolean object clearly. Looking at the focal region of the Boolean mirror we see: 
The zeroth order rays come to a geometrically perfect focus at the focal point of the parabola (although diffraction due to the aperture of the mirror prevents the spot size from being infinitesimally small: see the article on Point Spread Functions for more information). The + and -1 order rays show coma due to the phase added by the diffraction grating.
The Boolean object works by converting each parent object into a NURBS based representation, and then a series of Boolean trimming and combining operations are performed to yield the resulting object. Some loss of precision is possible when converting from ZEMAX native, high precision representations to NURBS representations; this is not a limitation of ZEMAX but is inherent in the NURBS representation of arbitrary surfaces. However, precision can be increased arbitrarily using the Spline and Tolerance parameters described in the manual. When extreme optical precision is required, the user should verify that the Boolean object traces to a suitable accuracy. We have tested this feature with sensitive aspheres and received very good results.
However in most cases where this feature is used, the default values of spline and tolerances will give very good results, as with the parabolic mirror in the previous example, but care should be taken with highly-balanced aspheres.
The other consequence of using NURBS is that more memory is required to hold the object, and ray-tracing is slower, than a comparable parametric object if one is available. It will be faster to trace, and require less memory to hold, the Standard Lens object than a Boolean combination of spheres and cylinders that yields the same shape and volume!
Built-in objects will always perform better than Boolean objects and should always be used when available. The user-defined object is also available to let you write your own parametric objects, if required. The Boolean object, however, gives great flexibility in defining unusual shapes easily and quickly.

The hexagonal lens is the Boolean AND of these two objects, and is fully parametric, and has whatever coating/scattering functions were applied to the parent objects.
Now delete the Boolean object, so that you have only the parent objects. In the Non-Sequential Component Editor, click on Tools->Combine Objects:

and fill in the resulting dialog as follows:

Note that the two parent objects are replaced with an Imported object, that has Face Mode = 3 (this means the faces are written out by ZEMAX).
