Skip to main content
Solved

Ignoring multiple surfaces at once, ZOSAPI, python


Hello fellow optics enthusiasts,

I’m currently working on a task where I need to ignore multiple surfaces in a Zemax optical system using the ZOS-API. At the moment, I’m using the following loop:

for i in range(150, 160):
    surface = TheSystem.LDE.GetSurfaceAt(i)
    surface.TypeData.IgnoreSurface = True

However, this approach seems to be quite slow. Has anyone found a more efficient way to ignore multiple surfaces at once?

Any insights or suggestions would be greatly appreciated!

Thanks in advance,
Sebastián

Best answer by chaasjes

I am afraid there are no alternatives to doing this in a loop.

However, do you run this in extension mode? Updating a boolean property doesn't take much time, but in extension mode, it takes some time to update the UI. If you are using the ZOS-API in extension mode, you'll see a significant speed-up if you take one of these measures:

  • Connect to OpticStudio in standalone mode;
  • Turn UI updates off before expensive operations and on again afterwards. You can do this with TheApplication.ShowChangesInUI = False # (or True)
View original
Did this topic help you find an answer to your question?

2 replies

chaasjes
Forum|alt.badge.img
  • Visible
  • 37 replies
  • Answer
  • June 6, 2025

I am afraid there are no alternatives to doing this in a loop.

However, do you run this in extension mode? Updating a boolean property doesn't take much time, but in extension mode, it takes some time to update the UI. If you are using the ZOS-API in extension mode, you'll see a significant speed-up if you take one of these measures:

  • Connect to OpticStudio in standalone mode;
  • Turn UI updates off before expensive operations and on again afterwards. You can do this with TheApplication.ShowChangesInUI = False # (or True)

Thanks a lot @chaasjes!

Yes, I’m using extension mode. I added TheApplication.ShowChangesInUI = False before the loop and set it back to True afte and now it’s much faster!

Really appreciate your help!

Sebastián


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