Skip to main content

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.

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


This macro doesn’t seem to work for me any longer. I’m on 2024R1.03. Does anyone know if this should work on the latest version?

Also, Has anyone made a version that enumerates lens surfaces? CodeV does this and it makes communicating specifics about the lens design easier.

Thanks,

John


@John.Hygelund

 

The macro seems to work on my side in R1.00. Could you tell us more about your issue? What is not working exactly? The macro is mostly based on text and relatively simple math, I find it hard to believe that an update has broken it. What I think is more likely is an issue with Windows.

I’ve looked at @MichaelH macro’s and aside from it being extremely well-thought, its core concept is to put the annotations in the clipboard through a shell command. This is really convenient, but you could also OUTPUT the annotations to a text file and copy them from there. I’m not at all expert in this area, but could it be a cyber-safety feature that prevents the execution of BAT files on your PC? You can comment the line where @MichaelH deletes the BAT file (once it has copied data into the clipboard) and print the path to this file. You can then navigate to this file and inspect its content.

  1. Comment the line 145, which deletes the BAT file, by adding a # in front of the line:
    #DELETEFILE tf$
  2. In line 95, add the following line to print the path to the BAT file:
    PRINT tf$
  3. Save and Run the macro
  4. In the Text Viewer, find the path to the BAT file towards the end:
     

     

  5. Open the file and check its content (right-click the file and open with a text editor), it should look like so:
     

As you can see, the first line clears your clipboard. Then, all that’s between the parenthesis is put into your clipboard. That is what should happen when this file is executed, which by the way, you can also execute by double-clicking on it.

I hope this helps, and take care,


David


Hello @David.Nguyen ,

Thanks for confirming that the macro works for you. I should have been more specific: the macro runs, but nothing is copied to the clipboard. As you mentioned, this is probably a Windows limitation. Your suggestion to save and access the .bat file works perfectly.

Now, I need to think about adding surface numbers…

Thanks again. Your responses have been very helpful.


Reply