Skip to main content

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

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


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


Reply