Skip to main content
Solved

Python _PythonStandaloneApplication object has no attribute 'TheApplication'


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

View original
Did this topic help you find an answer to your question?

4 replies

Yang.Yongtao
Fully Spectral
Forum|alt.badge.img
  • Author
  • Fully Spectral
  • 58 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
  • 58 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
  • 33 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
  • 58 replies
  • July 6, 2024
chaasjes wrote:

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings