As working directly on the system, each modification saves an UNDO file and the action is repeated for each Zernike coefficient, for each surfaces, that slows down the execution.
The actual way :
Get the system with :
TheSystem = TheApplication.PrimarySystem
and work on it directly
I tried to get a copy of the system with the CopySystem function, modify the copy and push it back :
TheSystem = TheApplication.PrimarySystem
new_system = TheSystem.CopySystem()
# does work here
TheSystem = new_system.CopySystem()
When looking at the surface type of TheSystem, I can see that it changed correctly, however it is not applied in the Zemax main window.
I used the TheSystem.UpdateStatus() function, but does not help.
Ideally my goal would be to be able to make all modifications outside of Zemax and update it when done, and hence get only one step of UNDO.
Is it possible in Python ? If so, what did I missed ?
Would that be possible in C# ?
Thank you for your help.
Page 1 / 1
@Sebastien G.
Its not available through the ZOSAPI (AFAIK), but you can disable the UNDO feature by changing: Setup..OpticStudio Preferences..General..Undo to None.
Then you can save the file at whichever stage of your design you want in the ZOSAPI.
I hope this helps and take care,
David
Hello,
thank you for your reply.
Yes I looked at this solution, but it is also not possible to change it programmatically, so I am not very keen to use it, as it is possible to forget to change it back.
There might be a solution to save a special .cfg and to load it at the beginning of the script and to reload the intial .cfg, but I have not tried it yet.
Hello,
loading a cfg file is not possible at any time, only before connecting to the API, so not relevant on how I wanted to use it.
// Define a Preferences File. // Preferences file is defined on the IZOSAPIConnection interface (prior to connecting to the API) // If no PreferencesFile is defined it will use the default OpticStudio.CFG file however changes will not persist between sessions. // If a PreferencesFile is defined, then any changes will save automatically. Console.WriteLine("===PreferencesFile==="); string cfgFile = @"C:\Users\Documents\Zemax\Configs\OpticStudio.CFG"; if (System.IO.File.Exists(cfgFile)) { TheConnection.PreferencesFile = cfgFile; Console.WriteLine("PreferencesFile: " + TheConnection.PreferencesFile); } else { Console.WriteLine("Default OpticStudio.CFG prefernces used"); }
So, as it is possible to work on a copy of the system (without any GUI update), I have modified my script to run as a MonteCarlo, and to save the best and worst runs.
Not exactly what I wanted to do, but at least it runs faster.