Hello Tom,
Thanks for your question here!
Regarding Option 1, the “constants” library is unique to the old Python setup that connected Python to the API through a COM link. This link required all enumerated variables be placed in a single library with the title “constants”. This connection type is discussed in the following knowledge base article: ZOS-API using Python
If you are using the COM link, then the correct syntax to change the update mode is:
TheSystem.UpdateMode = constants.LensUpdateMode_AllWindows
TheSystem.UpdateStatus()
However, in OpticStudio 20.2, we moved to a .NET connection. Now, Python’s syntax should be nearly identical to what you see in the Matlab examples we provide. You may learn more about this transition and its requirements here: ZOS-API using Python .NET
If you are using the .NET connection, then the correct syntax is as follows:
TheSystem.UpdateMode = ZOSAPI.LensUpdateMode.AllWindows
TheSystem.UpdateStatus()
Regarding Option 2, you do not need to use a loop if you are only updating one window. For example, if you know that the layout view is located at index 1, then you can use this line to update it:
TheSystem.Analyses.Get_AnalysisAtIndex(1).ApplyAndWaitForCompletion()
Best,
Csilla
Hi Csilla,
Thanks! The 'constants.LensuUpdateMode_AllWindows' approach worked!
Your reply raises a couple of related questions:
1. Is there a place where such information is listed, organized, and explained? Before posting here, I spent a long time searching for such keywords in the ZOS-API Syntax Help tool. And in fact, if you type 'LensUpdateMode_AllWindows' into the Search box (either Index or Topic), you get nothing.
2. I am still running OpticStudio 20.1. Your response ('in OpticStudio 20.2, we moved to a .NET connection') seems to imply that the old-fashioned COM link approach will no longer be supported. Is this true? I code my modest python programs in a standard text editor (and in fact on a Mac - I am a unix/Mac person and use the PC with Remote Desktop). Again, searching through the KnowledgeBase, it seems that I would have to download the many many gigabytes of Visual Studio and learn a whole new environment to do .NET programming (perhaps I am wrong about this...the KB article you referenced - 'ZOS-API using Python .NET' - makes no mention of Visual Studio). Also, I have depended heavily on the example code supplied with Zemax, and it seems to use COM exclusively. Have the examples been updated to .NET in version 20.2?
Thanks again and best wishes,
Tom