Skip to main content
Solved

Python _PythonStandaloneApplication object has no attribute 'TheApplication'

  • 5 July 2024
  • 4 replies
  • 92 views

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

 

4 replies

Userlevel 2
Badge

seems something wrong with the Initialize method

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

Userlevel 2
Badge

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

Userlevel 3
Badge

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.

Userlevel 2
Badge

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