Solved

How can I change the update mode in the ZOS-API?

  • 10 July 2019
  • 3 replies
  • 289 views

Userlevel 6
Badge +2

I'm using the Interactive Extension to add several lenses to my sequential system. To make the program run faster, I want to turn off OpticStudio's auto-update feature while the lenses are added and edited, then I want to turn it back on once that is done. How can I do this? 


icon

Best answer by Allie 10 July 2019, 19:40

View original

3 replies

Userlevel 6
Badge +2

To change the update mode of OpticStudio, we can use the UpdateMode property (found under the ZOSAPI.IOpticalSystem Interface Reference):

 





We see in the above image the UpdateMode is a part of the LensUpdateMode interface. If we click that in the help documentation, we are brought to a list of valid enumerators for this interface:






 


So, to be able to change the update mode, we have to call it from our system and set it equal to one of the enumerations available in the LensUpdateMode interface. 


The MATLAB syntax to turn auto-updating off would then look like the following:

 


TheSystem.UpdateMode = ZOSAPI.LensUpdateMode.None;



To change it back, we could replace "None" with "EditorsOnly" or "AllWindows".



For more information on ZOS-API syntax, check out the Knowledgebase article "Understand the basics of ZOS-API structure". 


In python, the None enumerator gives error, while the other two work correctly. It seems an overlap with the None python value. Here is the error:

>>> ZOSAPI.LensUpdateMode.None
                             ^
SyntaxError: invalid syntax

 

If I change the first letter’s case I correctly obtain the following error:

>>> ZOSAPI.LensUpdateMode.none

Traceback (most recent call last):
AttributeError: type object 'LensUpdateMode' has no attribute 'none'

Any idea?

Thank you

Userlevel 6
Badge +2

Hi @Iari.Marino - in this case, you can use the numerical value of the enumeration instead of the name. For the LensUpdateMode enumeration, “None” = 0, “EditorsOnly” = 1, and “AllWindows” = 2.

With that in mind, try this:

TheSystem.UpdateMode = 0
TheSystem.Save()
print(TheSystem.UpdateMode)

As far as I’m aware, all of the enumerators in the API index at 0. So you can pull up their listing in the Syntax Guide and identify which enumeration you want by number for any one, if you want.

Reply