Skip to main content
Question

Is there a build-in ZEMAX macro command to delete all surfaces in the lens table except the object and image?

  • November 3, 2024
  • 4 replies
  • 44 views

gsun86

I wrote a macro to do this but it is slow (line by line).  Is there a build-in method to do this?  I can’t find it in the user manual.

 

Thanks!

 

sub clear_all_lenses
    num_s = nsur()
    if (num_s > 2)
        for i, num_s-1, 1, -1
            !print "delete surface ",i
            delete i
        next
    endif
return

4 replies

David.Nguyen
Luminary
Forum|alt.badge.img+2
  • Luminary
  • 1085 replies
  • November 4, 2024

@gsun86 

 

Not sure that helps but when you press File..New, OpticStudio usually uses a file LENS.zos. This file has only 3 surfaces. Could you load this file with this command?

LOADLENS "LENS.zos"

It will erase all the content of the lens data editor, but it will also close all other windows, which probably you don’t want.

Anyway, just an idea.

Take care,


David


Forum|alt.badge.img
  • Ultraviolet
  • 99 replies
  • November 4, 2024

File->New also resets all of your settings in the system explorer, so it may be more work than selecting the surfaces in the file editor and then deleting them.


David.Nguyen
Luminary
Forum|alt.badge.img+2
  • Luminary
  • 1085 replies
  • November 4, 2024

@Ray

That’s true, I guess one could save an empty file with only two surfaces, but the correct System Explorer settings and session file, and load that file instead.

Take care,


David

 


gsun86
  • Author
  • Monochrome
  • 2 replies
  • November 4, 2024

Thanks Dave & Ray,

New file with the correct settings is a practical option.  We can also write the settings as macro functions as well - it will make the settings clear as a record.  


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings