Skip to main content

Hey gang, I saw this today: https://medium.com/codex/microsoft-integrates-python-natively-into-excel-ae2d1c794bab

Although I’ve not used it myself, I like how their simple integration of a new function =PY() gives Excel access to Python and all Python goodies.

Given the number of Pythonistas using OpticStudio via ZOS-API, and the great open-sourced Python links for OpticStudio (sorry I forget the name right now) it might be a relatively easy addition to make Python support built in. And a PYTH(filename$) function in ZPL would be soooo cool. 

Note this is already supported via the ZPL COMMAND keyword

COMMAND executable arguments

But this would be a relatively easy way to give more polished support for Python. In particular, COMMAND launches the executable in its own thread, and does not wait for completion. I think adding waiting for completion as an option

 

Hey Mark,

Some really cool ideas!

The one reason why my company isn’t using Python for Excel is it’s Azure based meaning all data/computations (both Excel and Python) need to be in the (public) Cloud; for many companies this would violate their InfoSec policies.  If Microsoft allows Python + Excel locally or behind a dedicated VPC, then that would be a really cool feature.

For the longest time, Zemax didn’t add native Python support because IronPython, which is Python written from the ground up in the .NET Framework, only supported Python 2.x.  In the middle of last year, IronPython3 officially went from “not recommended for production environments” to a stable release.  

IronLanguages/ironpython3: Implementation of Python 3.x for .NET Framework that is built on top of the Dynamic Language Runtime. (github.com)

OpticStudio already ships with 4 IronPython DLL’s from a previous attempt at integrating Python into OpticStudio (I believe these DLL’s are from IronPython2), so I think it would be a worthwhile effort for the Zemax Development Team to investigate again natively integrating Python into OpticStudio.  Having Python utilizing the same thread/conflict resolution as the ZPL would be incredibly powerful.


 

... Python for Excel is it’s Azure based meaning all data/computations (both Excel and Python) need to be in the (public) Cloud; for many companies this would violate their InfoSec policies.  

This would probably also make it “impossible” to connect to OpticStudio via the API, as the python code is run on a different computer. 

 

Reply