Solved

GetSag no longer working

  • 28 March 2022
  • 3 replies
  • 111 views

Hi,

I’ve been building over the years a series of python based-tools that use ZOSAPI framework in order to automatize repetitive jobs. However, the reccurent changes in the API causes regular failures in these scripts. Lately I’ve been trying to use a simple piece of code that gets the sag from the surfaces and find the following failure (where ZemaxLDE is an instance of the TheSystem.LDE, and xi, yj are points where I want my sag to be returned):

    tmp = ZemaxLDE.GetSag(index, xi, yj)


  File "C:\Python27\lib\site-packages\win32com\gen_py\EA433010-2BAC-43C4-857C-7AEAC4A8CCE0x0x1x0\ILensDataEditor.py", line 103, in GetSag
    , X, Y, sag, alternateSag)
  File "C:\Python27\lib\site-packages\win32com\client\__init__.py", line 467, in _ApplyTypes_
    self._oleobj_.InvokeTypes(dispid, 0, wFlags, retType, argTypes, *args),
pywintypes.com_error: (-2147352562, 'Nombre de param\xe8tres non valide.', None, None)

 

Could you please tell me what could have changed (I’m still working with Zemax 21.x because afraid of further failures) so that I get this error?

 

thanks much for your feedback,

icon

Best answer by Benoit.Borguet 31 March 2022, 15:02

View original

3 replies

Userlevel 7
Badge +2

Hi Benoit,

 

Not sure what’s going on, but perhaps you can find something useful here.

Take care,

 

David

Hi, thanks for your feedback, in the end I already had the solution. Sometimes when updating the OS or else I need to rerun the compilation for ZOSAPI to continue working smoothly. This is explained in one of the tutorials but I tend to forget what I learn ;).

Regards,

 

 

Userlevel 6
Badge +2

Hi @Benoit.Borguet - I’m glad you got it working! I wanted to note that the updated boilerplate for Python (which uses the .NET libraries) does not have this problem. For future projects, you could consider using that. Both types will continue to work with OpticStudio, but the .NET version is preferred. Here’s a quick guide on the biggest differences between the two connection types: What is the difference between Python COM and Python .NET? | Zemax Community

Reply