How to use the Boolean CAD, Boolean Native and Compound Lens objects, and the Combine Objects tool

This article is part of the Illumination Systems Fundamentals free tutorial.

OpticStudio supports the ability to create complex objects from other Non-Sequential Component (NSC) objects and surfaces.

Authored By Mark Nicholson & Sandrine Auriol


The Boolean Native object, the Boolean CAD object, and the Compound Lens object can be used to create complex objects from other objects and surfaces in Non-Sequential mode.

Boolean objects reference volumetric objects for Boolean operations while the Compound Lens object uses Non-Sequential surfaces to construct and combine the front and back geometry of a lens. Both of these object types reference preceding objects in the Non-Sequential Component Editor.

This article explains how to use the Boolean objects, and how to define scattering and diffraction properties on each surface. This article will also demonstrate how to use the Combine Objects tool to combine two objects and save the resulting object in a CAD file format.

The Boolean Native object

Start OpticStudio and open the file “Boolean Example 1 - basic operations.zmx” in user data folder {Zemax}\Samples\Non-sequential\Geometry Creation. This file consists of two sphere objects, which are object number 1 and 2, and a Boolean Native object, which is object 3. Scroll along to the right-hand side of the Non-Sequential Component Editor to see the properties of the Boolean Native object:


The Boolean Native object can take up to 10 "parent" objects, but in this case, we are using only two objects. The Boolean Native object can perform any of the following operations:

+ 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:

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 Native object A+B is directly above. Note that as the parent objects are parametric, the Boolean Native object is too: if the radius of either sphere is changed, the Boolean Native 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 Native object itself.

Surface properties of the Boolean Native 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 faces are inherited from the parent object:


Go to the Coat/Scatter properties for the Sphere object 1 and add an AR coating. Then, view the Coat/Scatter properties for the Boolean Native object 3. Face 0 of the Boolean Native object inherits the surface properties from the parent object 1:


The geometry of the parent objects define the volume of the Boolean Native object, and the Coat/Scatter properties of the parent objects define the Coat/Scatter properties of the Boolean Native object. This relationship is independent of the parent objects’ location relative to the Boolean object. Therefore, the parent objects can be located elsewhere in the system, or can be hidden and ignored. If the parent objects are not moved away from the Boolean Native object, or are not hidden and ignored, then the rays will interact with both the Boolean object and its parent objects. This is not typically the intended use case, so it is recommended that the parent objects are moved or ignored.

You can right click on the parent objects and select “Ignore and Hide Object”:


This sets "Rays Ignore Object" to Always and checks "Do Not Draw Object".

"Rays Ignore This Object" is under the Type tab of the object properties and is used if you do not want the objects to interact with rays.


"Do Not Draw Object" is under the Draw tab of the object properties and is used if you do not want to object to be drawn on screen.


Boolean operations

OpticStudio supports all Boolean operations, plus combinations of Boolean operations. Here are the basic operations. The parent objects A and B are drawn at the bottom of each window for reference

A OR B: Syntax A+B


A AND B: Syntax A&B


It's 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 CAD or Boolean Native object, and Boolean objects may also be the parent objects of other Boolean objects. This enables creation of very complex objects. The only restrictions are that parent objects must be defined prior to the Boolean object in the editor, and all operations are carried out in left-to-right order.

Here, for example, is a more complex Boolean object. It is available in the sample file “Boolean Example 4-  a lens mount.ZMX” in user data folder {Zemax}\Samples\Non-sequential\Geometry Creation:


The Boolean Native 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.

Diffraction and scattering

The diffractive and surface scattering properties of a parent object are inherited by the Boolean object too. For example, open the file “Boolean Example 3-  a diffractive scattering Boolean object.ZMX” in user data folder {Zemax}\Samples\Non-sequential\Geometry Creation.

In this case, the parent objects are a Diffraction Grating object, and an Extruded object based on the LETTERC.UDA sample file:


These objects 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:


Now the diffractive object has a parabolic surface shape, and the following surface properties on Face 1:



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 OpticStudio 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 object 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 infintesimally small: see the article "What is a Point Spread Function?" for more information.) The +1 and -1 order rays show coma due to the phase added by the diffraction grating.

The Boolean CAD object

The Boolean CAD object is similar to the Boolean Native object, but should only be used if the parent objects are imported CAD parts or objects that have a NURBS-based surface representation. The Boolean CAD 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.

The Boolean Native object doesn’t convert each component object into a NURBS-based surface representation, and instead uses the parent objects’ native geometry. For this reason, ray tracing with the Boolean Native object is more accurate and typically much faster (up to 10x faster) than the Boolean CAD object. Therefore, the Boolean Native object should be used for Boolean operations of native objects in OpticStudio.

The Boolean Native object is newer than the Boolean CAD object, so legacy files with Boolean CAD objects may require conversion to more efficient Boolean Native objects. OpticStudio will retain the parent object numbers when the object type is changed from Boolean CAD to Boolean Native, so this update should not require any manual data reentry.

When to use the Boolean Native object and the Boolean CAD object?

With a large number of parent objects:

The Boolean Native object and the Boolean CAD object are not recommended. Consider nesting the objects instead.

The ray tracing will be more accurate with the Boolean Native object, but the ray tracing speed may not be faster than ray tracing with the Boolean CAD object. This is because the rays still need to trace through all the parent objects and consider the Boolean geometry operations. Therefore, if many objects need to be combined, nesting the objects will likely ray trace faster than using the Boolean objects.

Designing a system with freeform surfaces:

The Boolean Native object is recommended.

The Boolean CAD object may result in a loss of precision when converting from OpticStudio native, high precision surface representations to NURBS-based representations. This is not a limitation of OpticStudio, but is inherent in the NURBS representation of arbitrary surfaces. See “How accurate is the CAD exchange?” for more information. The other consequence of using NURBS is that more memory is required to hold the object, so ray tracing is slower than with the Boolean Native object.

Parent objects are CAD objects:

Both Boolean objects can be used.

The Boolean Native object will not ray trace faster than the Boolean CAD object if the parent objects are not native objects in OpticStudio.

In general, native 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 Native object and Boolean CAD object, however, give great flexibility in defining unusual shapes easily and quickly.

The Combine Objects tool

The Boolean objects allow flexible operations upon up to 10 objects simultaneously and retains full parametric control of the object produced. In some cases, however, only two objects are required, and parametric control of the object is not needed. In these cases, the Combine Object Tool is useful.

First, two-parent objects are defined as usual. In this case, we will use the Extruded object. This takes an OpticStudio. UDA aperture file and extrudes it into the Z-direction. Open the sample file “Boolean Example 2-  a lens with a hexagonal edge.ZMX” in user data folder {Zemax}\Samples\Non-sequential\Geometry Creation:


The hexagonal lens is the Boolean AND of these two objects, 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:


Checking on “Replace Objects With New Combined Object” will simplify the editor if the parent objects are no longer needed.

You can also preview the object to confirm that you’ve selected the correct Boolean operation:


Click OK to create the new object. The two parent objects are replaced with a CAD Part: STEP/IGES/SAT object, with the following CAD settings:


The Compound Lens object

Whereas the Boolean objects and Combine Objects tool enable Boolean operations on volumetric NSC objects, the Compound Lens object creates a volume from two NSC surfaces. The Compound Lens object retains full parametric control of the object produced and is a very general lens object. It supports different surface types and apertures on the front and back faces. Both circular and rectangular apertures are supported.

The Compound Lens object is based on two-parent surface objects. Let’s say you have two surfaces: an Aspheric Surface object and a Toroidal Surface object.



You can define a Compound Lens object based on surface objects 1 and 2.

Compound Lens object

You can then define a circular or rectangular aperture with the “Is Rectangle?” parameter. For circular apertures, a chip zone and mechanical flat zone can also be defined. For example, you can define a circular aperture with a Clear semi-diameter of 4mm, a Chip semi-diameter of 5mm, and an Edge semi-diameter of 6mm.


Contrary to the Boolean objects, the Coat/Scatter properties of the Compound Lens object are not inherited from the parent objects.


Almost all NSC surface objects are supported as parent objects for the Compound Lens object, and additional surfaces may be added upon request.


Was this article helpful?
8 out of 8 found this helpful



Please sign in to leave a comment.