Skip to main content

Undocumented behavior of RemoveWavelength in the ZOSAPI

  • July 15, 2026
  • 0 replies
  • 7 views

David.Nguyen
Luminary
Forum|alt.badge.img+2

Hi all,

 

Don’t ask me how I got there… but I found a possibly undocumented (or not well documented let’s say) behavior of RemoveWavelength in the ZOSAPI (SystemData.Wavelengths).

In the user interface, if you keep removing wavelengths from the system, eventually you get down to a single wavelength, and this one cannot be suppressed. The enable checkbox grays out.

If you use RemoveWavelength enough times with a piece of code like so (I am using ZOSPy):

while True:
if not oss.SystemData.Wavelengths.RemoveWavelength(1):
break

print(oss.SystemData.Wavelengths.GetWavelength(1).IsActive)
print(oss.SystemData.Wavelengths.GetWavelength(1).Wavelength)

The prints will be as follows:

False
0.0

And if you use AddWavelength afterwards, this new wavelength will be at position 1 in the Wavelength Data Editor.

I am mentioning it because normally the ZOSAPI follows closely what the user interface does and this seems to be an exception. I like the exception because it means we can really clear the editor in one go, but I spent a lot of time troubleshooting an issue where I assumed I could never delete the last wavelength.

Hopefully you don’t loose your time with this also in the future.

Take care,


David