What is the Zemax Part Designer?

The Zemax Part Designer (ZPD) provides an interface that allows users to create and manipulate geometries in an environment separate from the current lens system. This article introduces the ZPD and instructs the user on the creation of a basic 3D geometry to be used in OpticStudio. In this tutorial, users will learn the basic workflow required to design geometries efficiently within the Zemax Part Designer.

Authored By Kevin Ting


The Zemax Part Designer (ZPD) console allows users to use commands and operations to quickly modify geometry and generate a new non-sequential object with the ZPO extension. Overall, the ZPD allows for a streamlined process to incorporate solid 3D geometry into a model in Non-Sequential Mode. 

This article introduces the ZPD and instructs the user on the creation of a basic 3D geometry to be used in OpticStudio. Users will learn a set of basic commands for a wide array of applications that can be viewed and modified once the ZPO file is generated. In this tutorial, users will learn the basic workflow required to design geometries efficiently within the ZPD.

Starting Zemax Part Designer

To start the Zemax Part Designer, switch OpticStudio into Non-Sequential Mode. In this article, we will be creating a Part Designer Object from scratch, so we can leave the first object as a Null Object for now. Navigate to Part Designer...Part Designer. This should launch the ZPD and spawn a new part window.


Launch the ZPD


The left side of the main window consists of the Script, Sketch, Gallery Mode, and Project Preferences Tabs. The Script Mode is a text editor in which users may input ZPD commands. A window just below the main text editor assists the user by displaying commands related to the current line of text or possible error messages.

The toolbar located at the top of the Part Designer window allows you to create or open a file and to alter your preferences and visual settings. The toolbar also contains commands for creating new objects and manipulating existing objects. All commands created from the tool ribbons are translated into ZPD commands and placed at the last position within the Script Mode window. For more details on the tool bar items, refer to the OpticStudio Help Files setion, "The Part Designer Tab."  


Modeling a CFL bulb

The remainder of this article will detail the creation of a CFL Light Bulb as shown below. This will involve several steps, including how to get started by inserting new commands, adding slits, finishing the bulb geometry, and adding a base unit. Finally, we will insert this bulb object to a non-sequential model in OpticStudio. 


CFL Light Bulb


Inserting new commands

A user may input commands manually via the text editor or select operations from the toolbar.  

We will begin the script with the spiraled glass section of the bulb. Let's add a comment to the top of the script to specify this. Click in the Script Mode window and type !BULB. By including the exclamation point, we have specified that this line should not be read by the script editor upon building. This is purely for our benefit, so as to keep track of the geometry. 

In the toolbar, click Objects and from the drop down list choose Spiral. This action will add a SPIRAL command to the script editor.




This will also open a dialog for you to enter the goemetry parameters. Ignore the default values present within the Spiral Dialog box and enter the following:


 Parameter  Value
 Object Name  Spiral1
 Radius  0.4
 Spiral Radius Front  2.0
 Spiral Radius Back  2.0
 Number of Turns  3
 Pitch  2.0




Press OK to insert the specified command into the Script Mode Console and the spiral we just created is shown in the ZPD 3D display. All new geometries have their “Length” aligned along the +Z-axis.




We now have the foundations of the bulb. A CFL bulb consists of two spiraled sections linked via a cylindrical tube, as shown below. The spiraled sections are then connected to the plastic base via two slits, also shown below. 


Cylindrical Tube(A)     Rounded Stilts(B)


In the following sections, let's add these components!


Building the stilts

As all new geometries created are aligned along the Z-axis, it will be easier to build the rest of the bulb by aligning the initial spiral with the origin. We can do so by using the "Move" command. Navigate to the toolbar, press Translate and choose Move from the drop down list.




This opens a MOVE control window. Currently, we see that the spiral is located at {X, Y, Z} = {1, 1, 1}. We know we will need to merge the spiral with the stilts, so we should update the location by specifying {X, Y, Z} = {-2.0, 0.0, 0.6} in the dialog. 



Now, we will use a Cylinder and a Sphere to build a single leg of the stilts. The parameters will be:


 Parameter  Value
 Object Shape  Cylinder
 Object Name  cylBulbBase
 Radius  0.4*1.05
 Length  0.6


 Parameter  Value
 Object Shape  Sphere
 Object Name  bulbBase
 Radius  0.4*1.05




Although multiplying certain values by 1.05 may seem very arbitrary and unnecessary, it is essential to include a scaling offset for parts that are to have boolean operations performed on them. For example, the stilts are to be combined with the spiral (with radial thickness of 0.4). Without the offset, the radial thickness of the stilts will be the same as that of the spiral. Combining the two parts will create surfaces that appear flush with each other. This is not ideal as converting the geometries into other 3D formats with flush surfaces will create undesired results. Therefore, flush/tangent faces and edges can be avoided by creating parts with slight offsets.      

The user may also notice that the same values are used multiple times, namely the offset value and the radial thickness of the spiral.  Users can make these values into preset parameters. Assigning these as parameters prior to their use can reduce confusion and allow easy modification of all commands utilizing these values in the future.

We can add parameters by using the keyword PARAMETER in the script editor. Once a parameter is specified, it may be used in any subsequent shape definitions. Let's replace our often-used values with parameters. In the Script Mode window, add the following lines after our comment:


PARAMETER offset, 1.05
PARAMETER bulbRad, 0.4
PARAMETER rad, 2.0


Once those are specified, we can replace those values in the already-created geometry. Once that's done, the script should read:


PARAMETER offset, 1.05
PARAMETER bulbRad, 0.4
PARAMETER rad, 2.0
SPIRAL Spiral1, bulbRad, rad, rad, 3, 2.0
MOVE Spiral1, -2.0, 0, 0.60
CYL cylBulbBase, bulbRad*offset, 0.6
SPHERE bulbBase, bulbRad*offset




Clicking each individual line, the user can view each command separately. The best method for seeing all necessary parts is to preemptively combine or boolean the commands that will be relevant.  For example, we know that the sphere and the cylinder will be combined to create a stilt, and the resulting part will be combined with the spiral to create a spiral shape connected to a rounded stilt. We can preemptively declare the boolean unions.


UNION bulbBaseround, bulbBase, cylBulbBase
UNION SpiralOneSide, Spiral1, bulbBaseround


At the end of the script, we can view these parts and easily adjust prior commands as needed.  By preemptively declaring such statements, the ZPD knows exactly what shapes will be relevant in the near future and will not factor them out of the rendering process. Knowing when and where to preempt such commands will dramatically improve the efficiency of designs within the Part Designer.

Additionally, in order for the stilts to attach to the spiral properly so its flat side is facing downward towards the bulb base, we need to flip it. This can be done using the "Reflect" command located in the "Translate" drop down button in the toolbar:    


Translate drop down button



In the Zemax Part Designer, the order of the script commands matters. So, we will need to rearrange what we currently have written. Now that the REFLECT command has been input, we can move it after the first UNION command. We will also need to tweak the location of the boolean object so that it renders properly. The updated script is below:


PARAMETER offset, 1.05
PARAMETER bulbRad, 0.4
PARAMETER rad, 2.0
SPIRAL Spiral1, bulbRad, rad, rad, 3, 2.0
MOVE Spiral1, -2.0, 0, 0.60
CYL cylBulbBase, bulbRad*offset, 0.6
SPHERE bulbBase, bulbRad*offset

UNION bulbBaseround, bulbBase, cylBulbBase
REFLECT bulbBaseround, 0.0, 0.0, 1.0, 0, 0, 1.0
MOVE bulbBaseround, 0,0,-1.39
UNION SpiralOneSide, Spiral1, bulbBaseround


Resulting script


Now, the sphere, “bulbBase,” needs to be positioned at the base of the spiral. Here is where ZPD’s “Ray” computation commands come in handy. This tool defines a ray at the specified x, y, and z point with the specified cx, cy, and cz direction cosines. Then, the ray is traced to the named object. We will trace a ray to cylBulbBase from {X, Y, Z, CX, CY, CZ} = {0.0, 0.0, 1.0, 0.0, 0.0, -1.0}.

Click Ray in the toolbar and enter the information.


Ray button


This specific Ray Computation will shoot a ray from the point (0, 0, 1) in free space along the negative Z-axis towards the cylindrical section of the stilt. Performing this calculation will create three new parameters: <DataTitle>.X, <DataTitle>.Y, and <DataTitle>.Z.  (Note that the X, Y, and Z must be capitalized.) The three data points represent the 3D coordinates of the point of intersection between the ray and the object. In this case, it returns the junction in which we need to position the sphere. Insert a “Position” command using the newly acquired Data Values by selecting Translate...Position from the toolbar.


Insert a Position command



The result of these two actions will produce two new commands:


RAY bulbBasePlacement, 0, 0, 1, 0, 0, -1, cylBulbBase
POSITION bulbBase, bulbBasePlacement.X, bulbBasePlacement.Y, bulbBasePlacement.Z, 0, 0, 1


Finishing the bulb

Move the center of resulting part over the origin and duplicate it.  Duplicating a part is performed with the "Copy" command and creates a newly named instance of the original part at the same location. To achieve the desired spiral effect, a union of two spirals must be formed, with one spiraling in the opposite direction. A "Mirror" operation cannot be used as our base object needs to be flipped along the X- and Y- axis. To perform this action, the "Scale" command is used instead, which can be found in the Shapes drop down option in the toolbar.





The resulting shape retains its size and shape along the Z-axis, but is flipped along the X- and Y-axis. Add a boolean operation between SpiralOtherSide and SpiralOnceSide. The new script commands are shown below:


MOVE SpiralOneSide,2,0,0
COPY SpiralOtherSide, SpiralOneSide
SCALE SpiralOtherSide,-1,-1,1
UNION Bulb, SpiralOtherSide, SpiralOneSide


Finally, to finish the bulb, a bridge between the two ends of the bulb must be created.  This is performed in a similar fashion to the stilts using the following part commands:


SPHERE bulbTip0, bulbRad*offset
CYL bulbTipCon, bulbRad*offset, 4
UNION bulbTip1, bulbTipCon, bulbTip0
SPHERE bulbTip2, bulbRad*offset
MOVE bulbTip2, 0, 0, 4
UNION bulbTipFin, bulbTip2, bulbTip1
POSITION bulbTipFin, -2, 0, 6.61, 1, 0, 0
UNION finalCFLBulb, bulbTipFin,Bulb


The Z-Coordinate (6.61) of the POSITION command (POSITION bulbTipFin, -2, 0, 6.61, 0, 0) was attained by multiplying the pitch of the initial spiral command (2.0) by the number of turns (3) and adding an offset based off the Radial Thickness. This method is not exact; therefore it may be necessary to double click certain elements of the final part to view and make fine adjustments to the positioning of the bridge.

To alter an existing ZSO command, double click the command in question. This will open the dialog box for recreating the command with the desired parameter values. Pressing “OK” replaces the current command.

The final bulb is shown below:


The resulting bulb


Adding the base

The base of the CFL Bulb is composed of multiple unions of a variety of cylinders and other shapes. To model these, we will start by creating the bulb end caps. Add a small cylinder created at the Origin. Note: If the mirroring plane used for a MIRROR command is centered at the origin, the base object must be offset first. 


CYL bulbPlasticBase, bulbRad+0.1, 0.3
MOVE bulbPlasticBase, -2,0,0
MIRROR bulbPlasticBase,0,0,0,1,0,0
UNION finalB0, finalCFLBulb, bulbPlasticBase


The above code will produce the following:




The remainder of the base is formed from multiple unions of cones, cylinders, and spheres. The ZPD commands to generate the shape are below:


CYL cflPlasticBase, 2.7, 2
MOVE cflPlasticBase, 0, 0, -2
CONE cflPlasticBase1, 1, 2.7, 2.2
MOVE cflPlasticBase1, 0, 0, -4
UNION cflPlasticBaseFin, cflPlasticBase1, cflPlasticBase
FILLET cflPlasticBaseFin, 0.05
CYL metalConnect, 1,2
MOVE metalConnect, 0,0,-5.5
SPHERE conductor,1.0*0.9
MOVE conductor, 0,0,-4.5-(1.0*0.9)
UNION contact,conductor,metalConnect
UNION wholeBase,cflPlasticBaseFin,contact
UNION cflTotal, wholeBase, finalB0


Take care to only “union” surfaces that are not flush with one another. For example, cflPlasticBase1 (the CONE command) was given a length of 2.2 units as opposed to 2.0 units and moved 4 units along the –Z-axis to obstruct the cflPlasticBase and create an overlap between the geometries. 




Finish the part by rotating the entire object -90 degrees about the X-Axis. The CFL bulb is now complete!




Save it by clicking Save As in the toolbar. This will open a dialog to save the part as a ZPO object directly to the "{Zemax}\Object\Part Designer Objects" folder. Save the object as "CFL_Bulb.zpo." 


Using the ZPD Object

ZPO files created within Non-Sequential Mode are stored in the "{Zemax}\Objects\Part Designer Objects" folder and can be accessed by changing the object type. Do this by clicking the drop down menu in the Object Type column of the Non-Sequential Component Editor and select "CAD Part: Zemax Part Designer." 




This will initiate a dialog prompting the user for a file to use:



Alternatively, you can navigate to Object Properties...Type and select Type: CAD Part: Zemax Part Designer from the drop-down menu and a ZPO file from the Data File drop-down menu.




This drop-down menu browses the default “Part Designer Object” folder saved within the OpticStudio settings and lists the ZPO files in that directory. Select "CFDBulb.ZPO" and you will see the newly-created geometry within the current lens system.




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



Article is closed for comments.