Skip to main content

Dear All,





I would be very grateful if someone is able to provide insight into an error we’ve experienced using the ZOS-API in Matlab please.





We are simply trying to execute demo code



“MATLABStandalone_04_pull_data_from_FFTMTF.m”



from the



“…Documents/Zemax/ZOS-API Sample Code/MATLAB” folder.



(It is also one of the examples in the webinar.)





At line 47:



“newWin_Settings.SampleSize = ZOSAPI.Analysis.SampleSizes.S_256x256;”



the code returns the following error:



“The class ZOSAPI.Analysis.SampleSizes has no Constant property or Static method named 'S_256x256'.”





Even when the default sampling in OpticStudio is manually changed to 256x256, such that


newWin_Settings.SampleSize =



_256x256



the same error occurs.





We are able to perform the analysis and get the expected result manually in OpticStudio, it is only the API interface that is problematic.





I would really appreciate any suggestions towards understanding the problem.



Please let me know if any additional information would be helpful.





Thank you in advance for your time in this respect.





Gareth





Hi Gareth,





I have seen that you have also sent your question to our support inbox.


But just to summarize, I have run the sample file "{Zemax}\ZOS-API Sample Code\MATLAB\MATLABStandalone_04_pull_data_from_FFTMTF.m" on the latest version of OpticStudio and it works fine on our side.

Are you using the latest version?





Sandrine




Hi Sandrine,





Thanks for your response.





The webinar uses OpticStudio 15, and runs the code just fine!


So it really can't be an issue with the specific version, right.





Gareth
Hi Gareth,





OpticStudio 15 had a bug in the sampling enumeration variables that was repaired in OpticStudio 15 SP1. The webinar was likely run in that version instead. 





To be able to use this command, you will need to upgrade to a newer version of OpticStudio. You can also manually open an FFT MTF, change the settings, and click the "SAVE" button on the settings dialog. Then the FFT MTF will open with those settings every time and you won't need to use the API to change the resolution. 





Let us know if you have any other questions about this!





Allie

Zemax OpticsStudio 20.1.3 



...


% Set up primary optical system


%TheSystem = TheApplication.CreateNewSystem(ZOSAPI.SystemType.Sequential);


sampleDir='C:\Applications\Zemax\Samples\Sequential\Objectives\';


lensFile = System.String.Concat(sampleDir,'Cooke 40 degree field.zmx');


%TheAnalyses = TheSystem.Analyses;


TheSystem = TheApplication.PrimarySystem;


TheLDE = TheSystem.LDE;


% Open a Diffraction Encircled Energy plot


diffEnergy = TheSystem.Analyses.New_Analysis(ZOSAPI.Analysis.AnalysisIDM.DiffractionEncircledEnergy);


% Update the settings to look at Ensquared energy instead


diffSettings = diffEnergy.GetSettings();


diffSettings.Type = ZOSAPI.Analysis.Settings.EncircledEnergy.EncircledEnergyTypes.Ensquared;


diffSettings.SampleSize = ZOSAPI.Analysis.SampleSizes.S_64X64;


!!!Error!!!


The class ZOSAPI.Analysis.SampleSizes has no Constant property or Static method named 'S_64X64'.



Error in ZemaxEEStandalone>BeginApplication (line 40)


diffSettings.SampleSize = ZOSAPI.Analysis.SampleSizes.S_64X64;



!!However!!


K>> disp(diffSettings.SampleSize)


S_64x64


Hi Don,



I notice one slight difference between the code under '!!!Error!!!' and the code under '!!However!!'. It looks like you input S_64X64 with a capital 'X'. For the sample size distinctions, the 'x' should be lower-case instead. The code will work with that update. I'm attaching a snippet below:



    TheSystem = TheApplication.PrimarySystem;


    TheLDE = TheSystem.LDE;


    % Open a Diffraction Encircled Energy plot


    diffEnergy = TheSystem.Analyses.New_Analysis(ZOSAPI.Analysis.AnalysisIDM.DiffractionEncircledEnergy);


    % Update the settings to look at Ensquared energy instead


    diffSettings = diffEnergy.GetSettings();


    diffSettings.Type = ZOSAPI.Analysis.Settings.EncircledEnergy.EncircledEnergyTypes.Ensquared;


    diffSettings.SampleSize = ZOSAPI.Analysis.SampleSizes.S_64x64;


    % Apply settings


    diffEnergy.ApplyAndWaitForCompletion();


Let us know if you have any other questions about this!



Best,



Allie


Reply