ZPL Macro: Create automatically annotations on a 3D layout to display distances between optics

  • 4 August 2022
  • 1 reply
  • 355 views

Userlevel 6
Badge +2

The attached ZPL will calculate the air space gaps between all elements and then will place the annotation text on the Windows clipboard.  After you run the script, simply open the Edit Annotation window, paste the text and click the Use Annotations checkbox:

 

For the Double Gauss 28 degree field.zmx, the 3D Layout will look like:

and for the Cooke 40 degree field.zmx:

 

Limitations:

  • You have to use the 3D Layout and not the 2d Layout.  The 3D Layout uses global coordinates for annotations while the Layout uses “window” units, meaning the values for LINE and TEXT would change based on the current zoom position.
  • For complete control, you should use LINE3D and TEXT3D (this would allow you to place things like CommentRadius, or Material on the plot as well.  For this simple example of air spaces, we will use MEASURE3D which is slightly easier to implement.
  • Since we're only looking at air spaces, you need to consider when you “enter” a cemented element (doublet, triplet, etc) and when you “exit” the element.  You cannot simply cycle through the LDE and look at the elements with something in the Material column.
  • This becomes much more difficult when you’re using off-axis, freeform, or folded systems since you need to calculate the placement of the lines/text in 3D space rather than just 2D space.
  • Since the annotations places the text on a defined plane, you need to know which Camera View Projection you're using.  This script uses the YZ plane.

1 reply

Userlevel 1

Hello Michael,

 

Great macro. I wish this could also support Fold mirrors/non-axial systems as well. This macro makes it so much easier to share the basic layout information.

I think OpticStudio should have this as inbuilt feature by default.

 

Best - AS

Reply