Skip to main content

Dear Zemax-Team,

I recently updated to Ansys R2.01. Since this moment, I got a lot of trouble running my code in the API environment using Python. 

The first few problems I encountered: 

  TheAnalyses = TheSystem.Analyses

  DistWin = TheAnalyses.New_Analysis(ZOSAPI.Analysis.AnalysisIDM.FieldCurvatureAndDistortion)

  DistWin_Settings = DistWin.GetSettings()

  DistWin_Settings.Wavelength.SetWavelengthNumber(1)

Results in the error:

  AttributeError: 'IAS_' object has no attribute 'Wavelength'

 

Or 

  PupilData=TheSystem.LDE.GetPupil(sysEnum, sysDbl,sysDbl,sysDbl,sysDbl,sysDbl,sysEnum,sysDbl)

has to be changed to 

  PupilData=TheSystem.LDE.GetPupil()

to work at all (correctly?!). 

 

Or declaration:

  normUnPolData.AddRay(np.int32(WLNo), np.double(Hx), np.double(Hy), np.double(-1), np.double(0), Enum.Parse(ZOSAPI.Tools.RayTrace.OPDMode, "None"))

is not working anymore and has to be changed to (from system lib):

  normUnPolData.AddRay(Int32(WLNo), Double(Hx), Double(Hy), Double(0), Double(0), Enum.Parse(ZOSAPI.Tools.RayTrace.OPDMode, "None"))

 

and so forth...

Everything worked quite fine until recently. Was there any major change? Does anybody else has problems here? Unfortunately, it is really cumbersome to experience changes in the structure of variables over time. 

 

Thank you and best regards,

 

Gregor

Hey Gregor,

Please see the post below.  The ZOS-API itself hasn’t changed, but rather a 3rd party Python module called PythonNET updated how they handle inheritance.  In short, all .GetSettings() now needs to be .GetSettings().__implementation__.

PythonNET 3.x is "Fixed" | Zemax Community


Thanks a lot! I wouldn’t have expected a Python problem here.