Hello. I have been learning how to use ZOS-API in Standalone mode with Python for a while now, but it seems that custom operands for optimization are only available using C# or C++. I have started working with C# (despite not knowing the language) and I have managed to get custom operands to work using this. Currently, I am working on connecting C# to Python so I can run my previously written scripts and then optimize the system based on some values calculated in Python. My current pipeline looks something like
- UDOC operand runs Python script
- Python script runs an instance of Zemax in Standalone mode and calculates some value
- Value is sent back to UDOC operand
- Zemax retrieves value
This setup somehow manages to work with just getting the value from Python into Zemax in the Merit Function Editor, but actually using the UDOC operand for optimization doesn’t seem to work and is also incredibly slow. A single cycle in the optimization loop can take over two minutes while retrieving the UDOC operand value in the Merit Function Editor only takes a couple of seconds, so I assume the main problem with this setup has something to do with the interaction between Zemax and Standalone Mode being looped due to the nature of optimization. My main question regarding this topic is whether or not there are other methods to creating custom operands using Python. Based on what I have done so far, I currently think that it is probably best to just convert most or even all of my current Python code into C#, which will be a daunting task as my code is quite complex. I have also considered making my own optimization algorithm in Python which would completely circumvent this issue. I want to hear some opinions regarding this matter before doing anything.