Skip to main content


TheSystem.Tools. SetAllRadiiVariable();

TheSystem.Tools. SetAllThicknessesVariable ();




  • Set all radii variables


  • Set all thicknesses variables




LocalOpt = TheSystem.Tools.OpenLocalOptimization();

LocalOpt.Algorithm = ZOSAPI.Tools.Optimization.OptimizationAlgorithm.DampedLeastSquares;

LocalOpt.Cycles = ZOSAPI.Tools.Optimization.OptimizationCycles.Automatic;

LocalOpt.NumberOfCores = 8;

LocalOpt.RunAndWaitForCompletion();

LocalOpt.Close();




  • Run local optimization with DLS






GlobalOptimTimeInSeconds = 15;

GlobalOpt = TheSystem.Tools.OpenGlobalOptimization();

GlobalOpt.Algorithm = ZOSAPI.Tools.Optimization.OptimizationAlgorithm.DampedLeastSquares;

GlobalOpt.NumberToSave = ZOSAPI.Tools.Optimization.OptimizationSaveCount.Save_10;

GlobalOpt.RunAndWaitWithTimeout(GlobalOptimTimeInSeconds);

GlobalOpt.Cancel();

GlobalOpt.WaitForCompletion();

GlobalOpt.Close();




  • Run global search and cancel it after 15 seconds




HammerOpt = TheSystem.Tools.OpenHammerOptimization();

HammerOpt.RunAndWaitWithTimeout(10);

HammerOpt.Cancel();

HammerOpt.WaitForCompletion();

HammerOpt.Close();




  • Run Hammer for 10 seconds




tol = TheSystem.Tools.OpenTolerancing();

tol.SetupMode = ZOSAPI.Tools.Tolerancing.SetupModes.Sensitivity;

tol.Criterion = ZOSAPI.Tools.Tolerancing.Criterions.RMSSpotRadius;

tol.CriterionSampling = 3;

tol.CriterionComp = ZOSAPI.Tools.Tolerancing.CriterionComps.OptimizeAll_DLS;

tol.CriterionCycle = 2;

tol.CriterionField = ZOSAPI.Tools.Tolerancing.CriterionFields.UserDefined;

tol.NumberOfRuns = 20;

tol.NumberToSave = 20;

tol.OutputFile= 'tol_output.txt';

tol.RunAndWaitForCompletion();

tol.Close();


In the above code:





  • Set up mode and criterion for the tolerancing analysis


  • Select 20 runs of Monte Carlo analysis and save them to 20 files


  • Save the tolerance analysis output window text to file ‘tol_output.txt’




MFcalculator=TheSystem.Tools.OpenMeritFunctionCalculator();

MFcalculator.RunAndWaitForCompletion;

MFvalue=MFcalculator.MeritFunctionCalculation;

MFcalculator.Close();






  • Calculate merit function




SpotCalculator= TheSystem.Tools.OpenRMSSpotRadiusCalculator();

SpotCalculator.SetMethodGaussianQuadrature(3, 6, 0);

SpotCalculator.IgnoreLateralColor= false;

SpotCalculator.AssumeAxialSymmetry= true;

SpotCalculator.RunAndWaitForCompletion();

SpotValue= RMS_SR.GetSpotRadius(1, 2);

SpotCalculator.Close();






  • Calculate RMS spot radius




DesignLockdown=TheSystem.Tools.OpenDesignLockdown();

DesignLockdown.UsePrecisionRounding= true;

DesignLockdown.DecimalPrecision=2;

DesignLockdown.ExcludePickups= true;

DesignLockdown.RunAndWaitForCompletion;

DesignLockdown.Close();







  • Run Design Lockdown




Lenscat=TheSystem.Tools.OpenLensCatalogs();

vendors=Lenscat.GetAllVendors();

Lenscat.SelectedVendor=vendors(1);

Lenscat.UseEFL=true;

Lenscat.MinEFL=5;

Lenscat.MaxEFL=10;

Lenscat.NumberOfElements=1;

Lenscat.RunAndWaitForCompletion();

Lenscat_results=Lenscat.GetResult(1);

Lenscat_results.InsertLensSeq(3,true,true);

Lenscat.Close();




  • Insert lens from stock lens catalogs at surface 3














Be the first to reply!

Reply