Skip to main content

Hi Zemaxers

 I am trying the python sample code of ZOS-API (as attached below). But it does not work at the first step.

https://support.zemax.com/hc/en-us/articles/4403605141267-Generate-the-executable-in-Python-for-ZOS-API-User-Extensions

 

The error shows as below

AttributeError: 'PythonStandaloneApplication' object has no attribute 'TheApplication'

(after checking the zemax install root , I guess it has something with 'TheApplication'  attribute)

 

Environment

python 3.10

PyCharm Community Edition 2022.1

Ansys Zemax OpticStudio 2024 R1.03

pythonnet version 3.0.3

Attached code 

 

What I have done:

checked the address below, it is correct

 

Could you give me some advice on this issue?

 

Thank you

 

YANG

 

seems something wrong with the Initialize method

I have tried a hard coded path, but it still does not work


Sorry for borthering here,

the fault is the wrong path

I shall use the C:\Program Files\Ansys Zemax OpticStudio 2024 R1.03

instead of    Documents\Zemax\ZOS-API\Libraries\ZOSAPI_NetHelper.dll


Hi @Yang.Yongtao ,

If you are getting started with using the ZOS-API from Python, I recommend trying ZOSPy: https://zospy.readthedocs.io/en/latest/

ZOSPy makes it easier to manage the connection and solves some problems related to Python.NET 3 that you will likely run into.


Hi @Yang.Yongtao ,

If you are getting started with using the ZOS-API from Python, I recommend trying ZOSPy: https://zospy.readthedocs.io/en/latest/

ZOSPy makes it easier to manage the connection and solves some problems related to Python.NET 3 that you will likely run into.

Thank you!

I will have a try


Reply