ZOS API in C# to get FftMtf returns null output

I am following the example (CSharpStandalone_04_pull_data_from_FFTMTF.cs) to get FFT MTF data like below;


IAR_ newWin_Results = newWin.GetResults();

It works fine in my computer. But the same copy returns ‘null results’ from other’s computer.

No idea where I should look into for debugging.

Appreciate your kind advice.




Best answer by MichaelH 23 May 2023, 18:10

View original

3 replies

Userlevel 6
Badge +2

Hi Sangyeol,

I think this is because the system on your coworker’s computer by default is non-sequential.  The ZOS-API has a check to see if TheSystem is sequential, non-sequential or both.  If TheSystem is non-sequential, even if it’s a new system (this comes from either the default Lens.ZMX file or the Setup > Project Preferences > General > Change Startup Defaults button), then sequential analysis will return null.  

Can you try calling the following command before you open up the analysis:


If this doesn’t work, can you upload more of your code?

Hi MichaelH,

Making theSystem sequential sounds great. 

Unfortunately, it didn’t work to get NULL when GetDataSeries is called. 

Again, it’s working nicely in my computer, but NULL from another computer.

I am posting more code below.



internal static double[,] CalculateFftMtf(IOpticalSystem theSystem, int szSample, int maxFreq)


            IA_ winFftMtf = theSystem.Analyses.New_FftMtf();


            IAS_FftMtf settings = winFftMtf.GetSettings() as IAS_FftMtf;


            settings.SampleSize = (ZOSAPI.Analysis.SampleSizes)szSample;


            settings.MaximumFrequency = maxFreq;




            IAR_ results = winFftMtf.GetResults();


            IAR_DataSeries dataSeries = results.GetDataSeries(1);

            if (dataSeries == null)

                return null;





Userlevel 6
Badge +2

Ah, I thought the GetResults() was giving an error (I couldn’t remember off the top of my head if the null is on GetResults or ApplyAndWaitForCompletion when running and analysis in the wrong mode). 

I didn’t realize it’s the GetDataSeries().   This means that the analysis didn’t complete and there was an error.  For example, if you don’t load the correct system and you’re working off the default Lens.zmx file with only 3 surfaces and no Entrance Pupil, you get a dataSeries == null and you get the following error in the GUI:

 Since the error will be more detailed in the GUI, I would suggest adding the following line after the ApplyAndWaitForCompletion() then open the file and check the error:

theSystem.SaveAs(System.IO.Path.Combine(theSystem.TheApplication.SamplesDir, "ZOSAPI_test.zmx"));