Home 9 Rapid Prototyping 9 Zemax Macro

Zemax Macro

The method used by the LightForge_GridXYZ ZEMAX macro to generate a LightForge compatible GridXYZ file from an optical design in ZEMAX is described below. This macro is only suitable for operation in the Non-Sequential mode of ZEMAX. 

Download the Zemax macro here: LightForge_GridXYZ.zip

Download Zemax Macro Data Sheet here.  PDF icon ZEMAX to GridXYZ Macro Operation_March 2016.pdf.

Macro operation

The LightForge_GridXYZ macro works by creating a source ray, which is then moved in a raster scan pattern over a defined xy range while measuring the z-intercept of the first surface intersected in the ZEMAX system.  This data is simultaneously written to an external file in a user-selected folder location and then converted to ANSI format for upload to the LightForge website.

Setting up your system

The macro must first be installed on the system:

  • Copy the LightForge_GridXYZ.zpl file to the folder located at Root Drive:\Users\Your User Name Here\Documents\ZEMAX\Macros
  • If ZEMAX was opened when the macro was copied, open the Macros drop down menu and select “Refresh Macro List”.  You should now see LIGHTFORGE_GRIDXYZ in your macro list

Lens units of the system should be set to millimetres in the General window under the Units tab.

The ZEMAX system must be set up to provide an accurate representation of the desired surface with the range sampled by the macro.  The surface to be sampled must have the following parameters.

  • Must be the first surface intersected by a ray if the ray is object 1
  • Centred in x and y • Full x and y dimensions smaller than or equal to 15mm
  • z position must be great than zero

The entire 15x15mm area sampled by the macro needs to be fully specified so, for example, a radial optic must also be partnered with a square dummy surface in order for the sampling ray to intersect a surface in the corners of the sampling region.  The simplest way to do this is by adding a rectangle object with X and Y Half Widths of 7.5mm, and located +50um in z from your front surface (this ensures that manufacturing rules are adhered to).  The surface can be placed at other locations, including the z position of the lens, but a Boolean object must be constructed in order to create a window for the sampling ray to intersect the desired surface.

Example system

Here is presented a simple example system showing the setup required when using the macro to sample a lens surface in ZEMAX. 

A Standard Lens object in ZEMAX

A Standard Lens object is created with a radius of curvature of 500mm and a radial dimension of 7.5mm, centred in x and y and with a z-position of 0.005mm:

A Standard Lens object with a Rectangle object acting as a dummy surface (shown in red)

As mentioned before, the macro will not produce a correct result when the sampling ray does not intersect with a surface, so a dummy surface is made by creating a Rectangle object with X and Y half widths of 7.5mm and a z-position of 0.05mm: 

The system is now ready to be sampled using the Lightforge_GridXYZ macro.  To do so, select LIGHTFORGE_GRIDXYZ from the macro list and you will be prompted for a location to save the file, after which the macro will produce a file called LightForge_gridXYZ.dat at the target location.