Hi all,
I am facing an issue when using the Image Simulation tool via the ZOS-API. The goal is to vary a certain variable in a loop (in this case the object distance), perform each time an image simulation, and save the image with a specific name to a file. However, I notice that the previous images are always overwritten when a new image is saved.
This is the simple MATLAB code that I am using in the main body:
sampleDir = 'D:\Zemax OpticStudio\';
testFile = System.String.Concat(sampleDir, '\Test_ImageTelecentric_Issue.zos');
TheSystem.LoadFile(testFile,false);
TheSystem = TheApplication.PrimarySystem;
TheLDE = TheSystem.LDE;
zline = 0;
surface = TheLDE.GetSurfaceAt(zline);
zvec = =1100,1500]; %variable object distance
for z = zvec
surface.Thickness = z;
index = 3; %existing Image Analysis window with correct settings
im_analysis = TheSystem.Analyses.Get_AnalysisAtIndex(index);
im_settings = im_analysis.GetSettings;
im_settings.OutputFile = ='z',num2str(z),'.png']; %change file name according to variable
im_analysis.ApplyAndWaitForCompletion(); %save image
TheSystem.Save();
end
Although I seem to change the OutputFile before running the analysis, the previous image is always being overwritten:
The ZEMAX archive file is found in attachment.
I would be very glad if someone could point out what the issue could be.
Thanks,
Indy