Skip to main content
Question

ZOS-API Python how to access HuygensPsfCrossSection settings


lin
  • Single Emitter
  • 1 reply

Hello,

I’m trying to convert the following C# code snippet:

var hpsf =TheSystem.Analyses.New_Analysis(AnalysisIDM.HuygensPsfCrossSection);

var hpsf_settings = hpsf.GetSettings() as IAS_HuygensPsfCrossSection;

hpsf_settings.PupilSampleSize = (SampleSizes)(_pupilSampling + 1);

hpsf_settings.ImageSampleSize = (SampleSizes)(_imageSampling + 1);

hpsf_settings.ImageDelta = 0;

into Python:

hpsf= TheSystem.Analyses.New_Analysis(ZOSAPI.Analysis.AnalysisIDM.HuygensPsfCrossSection)

hpsf_setting=hpsf.GetSettings()

hpsf_settings.ImageDelta = 0

but I got error message

AttributeError: 'IAS_' object has no attribute 'ImageDelt

How can I cast  hpsf_setting returned by GetSettings() into a HuygensPsfCrossSection specific object?

Thank you very much!

 

lin

2 replies

Benjamin.N
Forum|alt.badge.img
  • Visible
  • 34 replies
  • August 3, 2023

Hi lin,

this sounds like a known issue with PythonNET 3.x for which @MichaelH provided a nice workaround recently:
PythonNET 3.x is "Fixed" | Zemax Community

In short: replace

hpsf_setting=hpsf.GetSettings()

with

hpsf_setting = hpsf.GetSettings().__implementation__

and your code should work.

Best regards
Benjamin


lin
  • Author
  • Single Emitter
  • 1 reply
  • August 3, 2023

Thank you very much, Benjamin, for your helpful answer!


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