Solved

GetFirstOrderData() exception

  • 17 October 2022
  • 2 replies
  • 127 views

Userlevel 1

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

icon

Best answer by MichaelH 17 October 2022, 17:59

View original

2 replies

Userlevel 6
Badge +2

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