Skip to main content
Solved

Python _PythonStandaloneApplication object has no attribute 'TheApplication'

  • July 5, 2024
  • 4 replies
  • 354 views

Yang.Yongtao
Fully Spectral
Forum|alt.badge.img

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

 

Best answer by Yang.Yongtao

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

4 replies

Yang.Yongtao
Fully Spectral
Forum|alt.badge.img
  • Author
  • Fully Spectral
  • 76 replies
  • July 5, 2024

seems something wrong with the Initialize method

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


Yang.Yongtao
Fully Spectral
Forum|alt.badge.img
  • Author
  • Fully Spectral
  • 76 replies
  • Answer
  • July 5, 2024

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


chaasjes
Forum|alt.badge.img
  • Visible
  • 38 replies
  • July 5, 2024

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.


Yang.Yongtao
Fully Spectral
Forum|alt.badge.img
  • Author
  • Fully Spectral
  • 76 replies
  • July 6, 2024

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