Skip to main content
Solved

GetFirstOrderData() exception

  • October 16, 2022
  • 2 replies
  • 156 views

  • Ultraviolet
  • 27 replies

Hello,

Getting first order data ends in error: TypeError: No method matches given arguments with python 3.6.13 and pythonnet  2.3.0

Works fine with python 3.10 and pythonnet 3.0.0.post1 (but alas I cannot use pythonnet 3.0 because I have had problems with other aspects of ZOSAPI)

ZOSAPI Python code used to test:

TheSystem.LDE.GetFirstOrderData() # ZOSAPI.Editors.LDE.ILensDataEditor.GetFirstOrderData

 

Any workarounds are greatly appreciated.

-A

Best answer by MichaelH

Hi Asuku,

With pyhtonnet 2.5.2 (and earlier), you need to pass in dummy placeholders when calling some specific functions, namely any function with the out keyword as an argument.  For the GetFirstOrderData, there are 5 out parameters so there needs to be 5 dummy values passed into the function.  The output for a function like this will always be the out parameters + 1 (the actual return from the function):

There are some functions, specifically the AddRay() in the IBatchRayTrace interface where pythonnet won’t be able to actually dynamically cast the dummy placeholders to the correct object type so you’ll need to explicitly pass in a System.Double or a System.Int value (this is because there are multiple methods called AddRay() in the same parent interface and the desired method become ambiguous).  You also need to make sure you pass in ZOSAPI enums if the method requires it.

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

2 replies

MichaelH
Ansys Staff
Forum|alt.badge.img+2
  • Ansys Staff
  • 342 replies
  • Answer
  • October 17, 2022

Hi Asuku,

With pyhtonnet 2.5.2 (and earlier), you need to pass in dummy placeholders when calling some specific functions, namely any function with the out keyword as an argument.  For the GetFirstOrderData, there are 5 out parameters so there needs to be 5 dummy values passed into the function.  The output for a function like this will always be the out parameters + 1 (the actual return from the function):

There are some functions, specifically the AddRay() in the IBatchRayTrace interface where pythonnet won’t be able to actually dynamically cast the dummy placeholders to the correct object type so you’ll need to explicitly pass in a System.Double or a System.Int value (this is because there are multiple methods called AddRay() in the same parent interface and the desired method become ambiguous).  You also need to make sure you pass in ZOSAPI enums if the method requires it.


I have the same probleme, even when I try the above I get :

 

    ZOSAPI.Editors.LDE.ILensDataEditor.GetFirstOrderData(0.0,0.0,0.0,0.0,0.0)

TypeError: No method matches given arguments for GetFirstOrderData: (<class 'float'>, <class 'float'>, <class 'float'>, <class 'float'>)

 

I also tried using:

sysDbl = Double(1.0)

ZOSAPI.Editors.LDE.ILensDataEditor.GetFirstOrderData(sysDbl,sysDbl,sysDbl,sysDbl,sysDbl)
Traceback (most recent call last):

  File "<ipython-input-40-6fd9590700d0>", line 1, in <module>
    ZOSAPI.Editors.LDE.ILensDataEditor.GetFirstOrderData(sysDbl,sysDbl,sysDbl,sysDbl,sysDbl)

TypeError: No method matches given arguments for GetFirstOrderData: (<class 'System.Double'>, <class 'System.Double'>, <class 'System.Double'>, <class 'System.Double'>)

 

Any idea why this is happening ?

 


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