Skip to main content

ZOS-API interface 2025 R1

ZOSAPI.Tools.IOpticalSystemTools Interface Reference

Last update: 17.07.2025

Methods to run various system-wide tools. This interface can be accessed via the IOpticalSystem interface. Note that only one ISystemTool can be open at a time; the previous tool must be closed using ISystemTool.Close before a new one can be opened. More...

Public Member Functions

IBatchRayTrace OpenBatchRayTrace ()
 Opens the Batch Ray Trace tool.
 
INSCRayTrace OpenNSCRayTrace ()
 Creates a new NSC Ray Trace instance. Note – only one instance of this tool can be open at a time. See the INSCRayTrace documentation for more information.
 
IQuickAdjust OpenQuickAdjust ()
 Opens the Quick Adjust tool.
 
IQuickFocus OpenQuickFocus ()
 Opens the Quick Focus tool.
 
ILightningTrace OpenLightningTrace ()
 Opens the Lightning Trace tool.
 
IFindBestAsphere OpenFindBestAsphere ()
 Opens the Find Best Asphere tool.
 
IConvertAsphereType OpenConvertAsphereTypes ()
 Opens the Convert Asphere Types tool.
 
ILocalOptimization OpenLocalOptimization ()
 Opens the Local Optimization tool.
 
IGlobalOptimization OpenGlobalOptimization ()
 Opens the Global Optimization tool.
 
IHammerOptimization OpenHammerOptimization ()
 Opens the Hammer Optimization tool.
 
ITolerancing OpenTolerancing ()
 Opens the Tolerancing tool.
 
IRestoreArchive OpenRestoreZAR ()
 Opens the Restore Zemax Archive (ZAR) tool.
 
ICreateArchive OpenCreateZAR ()
 Opens the Create Zemax Archive (ZAR) tool.
 
IRestoreProject OpenRestoreProject ()
 
ICreateProject OpenCreateProject ()
 
IExportCAD OpenExportCAD ()
 Opens the Export to Cad tool.
 
IScale OpenScale ()
 Opens the Scale Lens tool.
 
IMFCalculator OpenMeritFunctionCalculator ()
 Opens the Merit Function Calculator tool.
 
ILensCatalogs OpenLensCatalogs ()
 Opens the Lens Catalogs tool.
 
IConvertToNSCGroup OpenConvertToNSCGroup ()
 Opens the Convert to NSC Group tool.
 
IDesignLockdown OpenDesignLockdown ()
 Opens the Design Lockdown tool.
 
ICriticalRaysetGenerator OpenCriticalRaysetGenerator ()
 Opens the critical rayset generator tool.
 
bool RemoveAllVariables ()
 Removes all variables in the system.
 
int SetAllRadiiVariable ()
 Makes all radii in the system variable.
 
int SetAllThicknessesVariable ()
 Makes all thicknesses in the system variable.
 
double[] CreateDoubleVector (int numElements)
 Creates a 1D array of doubles. This is primarily useful when you need to create a SAFEARRAY for access to the API from a COM-based interface.
 
double[,] CreateDoubleMatrix (int Rows, int Cols)
 Creates a 2D matrix double doubles. This is primarily useful when you need to create a SAFEARRAY for access to the API from a COM-based interface.
 
IZRDReader OpenRayDatabaseReader ()
 
IComputeRMSSpotSize OpenRMSSpotRadiusCalculator ()
 Opens the RMS spot radius calculator. Note that this is only valid in sequential mode.
 
double GetConversionToSystemUnits (ZemaxSystemUnits fromUnits)
 Gets the conversion factor from the specified units to system units. Returns s such that [x' = s * x] where x is in "fromUnits" and x' is in system units.
 
double GetConversionFromSystemUnits (ZemaxSystemUnits toUnits)
 Gets the conversion factor from system units to the specified units. Returns s such that [x' = s * x] where x is in system units and x' is in "toUnits".
 
IShadedModelVisualizationExport OpenShadedModelVisualizationExport ()
 Opens the Shaded Model Visualization export tool. This tool allows retreieving a list of triangles representing the solid models used for Shaded Model visualization.
 
IMaterialsCatalog OpenMaterialsCatalog ()
 
IQuickSensitivity OpenQuickSensitivity ()
 
IToleranceDataViewer OpenToleranceDataViewer ()
 
IRayAimingWizard OpenRayAimingWizard ()
 
IHPCSettings GetHPCSettingsFromPrefs ()
 
IHPCSettings GetHPCSettingsCustom (int nodeCount, HPCNodeSize instanceType)
 
INSCRayTrace OpenNSCRayTrace_HPC (IHPCSettings hpcSettings)
 
ITolerancing OpenTolerancing_HPC (IHPCSettings hpcSettings)
 
IGlobalOptimization OpenGlobalOptimization_HPC (IHPCSettings hpcSettings)
 
IHammerOptimization OpenHammerOptimization_HPC (IHPCSettings hpcSettings)
 
IPointTools GetPointTools ()
 
IHullTools GetHullTools ()
 
IFileManager OpenFileManager ()
 
FileManager.IConvertProjectToFileTool OpenProjectToFileConverter ()
 
IExportToSpeosLensSystem OpenExportToSpeosLensSystem ()
 
IExportToSpeosWhitebox OpenExportToSpeosWhitebox ()
 
IAPIUtilities GetUtilities ()
 

Properties

ISystemTool CurrentTool [get]
 Gets the currently open tool. Note that if a tool is already open, all attempts to open a new tool will fail.
 
int Progress [get]
 Gets the progress of the currently running tool, if the tool reports incremental progress.
 
string Status [get]
 Gets the status of the currently running tool, if the tool reports incremental status messages.
 
bool IsRunning [get]
 Gets a value indicating whether the CurrentTool is currently running asynchronously.
 
ILayouts Layouts [get]
 
IMessage LastError [get]
 

Detailed Description

Methods to run various system-wide tools. This interface can be accessed via the IOpticalSystem interface. Note that only one ISystemTool can be open at a time; the previous tool must be closed using ISystemTool.Close before a new one can be opened.

Usage (see Example 15 for a full sample)

C#

// remove all variables and add a F# solve on last surface radius
ILensDataEditor TheLDE = TheSystem.LDE;
IOpticalSystemTools tools = TheSystem.Tools;
ILDERow Surface_Last = TheLDE.GetSurfaceAt(TheLDE.NumberOfSurfaces - 2);
ISolveData Solver = Surface_Last.RadiusCell.CreateSolveType(ZOSAPI.Editors.SolveType.FNumber);
Solver._S_FNumber.FNumber = 3.1415;
Surface_Last.RadiusCell.SetSolveData(Solver);
SampleFile = System.IO.Path.Combine(TheApplication.SamplesDir, @"API\CS\e15_Seq_Optimization\OptimizedFile1.zos");
TheSystem.SaveAs(SampleFile);
Methods to run various system-wide tools. This interface can be accessed via the IOpticalSystem inter...
Definition: Tools.cs:107
bool RemoveAllVariables()
Removes all variables in the system.
Definition: InterfacesEditors.cs:12
The ZOSAPI namespace contains classes for initially connecting to zemax. See also ZOSAPI_Connection,...
Definition: IAS_FieldCurvatureAndDistortion.cs:5

C++

// remove all variables and add a F# solve on last surface radius
ILensDataEditorPtr TheLDE = TheSystem->LDE;
//IOpticalSystemTools
IOpticalSystemToolsPtr tools = TheSystem->Tools;
tools->RemoveAllVariables();
ILDERowPtr Surface_Last = TheLDE->GetSurfaceAt(TheLDE->NumberOfSurfaces - 2);
ISolveDataPtr Solver = Surface_Last->RadiusCell->CreateSolveType(SolveType::SolveType_FNumber);
Solver->_S_FNumber->FNumber = 3.1415;
Surface_Last->RadiusCell->SetSolveData(Solver);
SampleFile = _bstr_t(TheApplication->SamplesDir) + "\\API\\\Seq_Optimization\\\OptimizedFile1.zos";
TheSystem->SaveAs(SampleFile);

Matlab

% remove all variables and add a F# solve on last surface radius
TheLDE = TheSystem.LDE;
tools = TheSystem.Tools;
tools.RemoveAllVariables();
Surface_Last = TheLDE.GetSurfaceAt(TheLDE.NumberOfSurfaces - 2);
Solver = Surface_Last.RadiusCell.CreateSolveType(ZOSAPI.Editors.SolveType.FNumber);
Solver.S_FNumber_.FNumber = 3.1415;
Surface_Last.RadiusCell.SetSolveData(Solver);
SampleFile = System.String.Concat(TheApplication.SamplesDir, '\API\Matlab\e15_Seq_Optimization\OptimizedFile1.zos');
TheSystem.SaveAs(SampleFile);

Python

# remove all variables and add a F# solve on last surface radius
TheLDE = TheSystem.LDE
#IOpticalSystemTools
tools = TheSystem.Tools
tools.RemoveAllVariables()
Surface_Last = TheLDE.GetSurfaceAt(TheLDE.NumberOfSurfaces - 2)
Solver = Surface_Last.RadiusCell.CreateSolveType(ZOSAPI.Editors.SolveType.FNumber)
Solver._S_FNumber.FNumber = 3.1415
Surface_Last.RadiusCell.SetSolveData(Solver)
SampleFile = TheApplication.SamplesDir + '\\API\\Python\\e15_Seq_Optimization\\OptimizedFile1.zos'
TheSystem.SaveAs(SampleFile)
Examples
CSharpStandalone_15_Seq_Optimization.cs.

Member Function Documentation

◆ CreateDoubleMatrix()

double[,] ZOSAPI.Tools.IOpticalSystemTools.CreateDoubleMatrix ( int  Rows,
int  Cols 
)

Creates a 2D matrix double doubles. This is primarily useful when you need to create a SAFEARRAY for access to the API from a COM-based interface.

Parameters
RowsThe number of rows in the output matrix.
ColsThe number of columns in the output matrix.
Returns

◆ CreateDoubleVector()

double[] ZOSAPI.Tools.IOpticalSystemTools.CreateDoubleVector ( int  numElements)

Creates a 1D array of doubles. This is primarily useful when you need to create a SAFEARRAY for access to the API from a COM-based interface.

Parameters
numElementsThe number elements in the output array.
Returns

◆ GetConversionFromSystemUnits()

double ZOSAPI.Tools.IOpticalSystemTools.GetConversionFromSystemUnits ( ZemaxSystemUnits  toUnits)

Gets the conversion factor from system units to the specified units. Returns s such that [x' = s * x] where x is in system units and x' is in "toUnits".

Parameters
toUnitsTo units.
Returns

◆ GetConversionToSystemUnits()

double ZOSAPI.Tools.IOpticalSystemTools.GetConversionToSystemUnits ( ZemaxSystemUnits  fromUnits)

Gets the conversion factor from the specified units to system units. Returns s such that [x' = s * x] where x is in "fromUnits" and x' is in system units.

Parameters
fromUnitsFrom units.
Returns

◆ GetHPCSettingsCustom()

IHPCSettings ZOSAPI.Tools.IOpticalSystemTools.GetHPCSettingsCustom ( int  nodeCount,
HPCNodeSize  instanceType 
)

◆ GetHPCSettingsFromPrefs()

IHPCSettings ZOSAPI.Tools.IOpticalSystemTools.GetHPCSettingsFromPrefs ( )

◆ GetHullTools()

IHullTools ZOSAPI.Tools.IOpticalSystemTools.GetHullTools ( )

◆ GetPointTools()

IPointTools ZOSAPI.Tools.IOpticalSystemTools.GetPointTools ( )

◆ GetUtilities()

IAPIUtilities ZOSAPI.Tools.IOpticalSystemTools.GetUtilities ( )

◆ OpenBatchRayTrace()

IBatchRayTrace ZOSAPI.Tools.IOpticalSystemTools.OpenBatchRayTrace ( )

Opens the Batch Ray Trace tool.

Usage (see Example 22 for a full sample)

C#

// Set up Batch Ray Trace
ZOSAPI.Tools.RayTrace.IBatchRayTrace raytrace = TheSystem.Tools.OpenBatchRayTrace();
int nsur = TheSystem.LDE.NumberOfSurfaces;
int max_rays = 30;
ZOSAPI.Tools.RayTrace.IRayTraceNormUnpolData normUnPolData = raytrace.CreateNormUnpol((max_rays + 1) * (max_rays + 1), ZOSAPI.Tools.RayTrace.RaysType.Real, nsur);
Interfaces and methods for running a ray trace on multiple rays at a time. This interface can be acce...
Definition: RayTrace.cs:239
IRayTraceNormUnpolData CreateNormUnpol(int MaxRays, RaysType rayType, int toSurface)
Performs a batch unpolarized ray trace, using normalized pupil coordinates. See the OpticStudio help ...
Definition: RayTrace.cs:12
Definition: FileSource.cs:4

C++

// Set up Batch Ray Trace
IBatchRayTracePtr raytrace = TheSystem->Tools->OpenBatchRayTrace();
int nsur = TheSystem->LDE->NumberOfSurfaces;
int max_rays = 30;
IRayTraceNormUnpolDataPtr normUnPolData = raytrace->CreateNormUnpol((max_rays + 1) * (max_rays + 1), RaysType::RaysType_Real, nsur);

Matlab

% Set up Batch Ray Trace
raytrace = TheSystem.Tools.OpenBatchRayTrace();
nsur = TheSystem.LDE.NumberOfSurfaces;
max_rays = 30;
normUnPolData = raytrace.CreateNormUnpol((max_rays + 1) * (max_rays + 1),ZOSAPI.Tools.RayTrace.RaysType.Real,nsur);

Python

# Set up Batch Ray Trace
raytrace = TheSystem.Tools.OpenBatchRayTrace()
nsur = TheSystem.LDE.NumberOfSurfaces
max_rays = 30
normUnPolData = raytrace.CreateNormUnpol((max_rays + 1) * (max_rays + 1), ZOSAPI.Tools.RayTrace.RaysType.Real, nsur)
Returns

◆ OpenConvertAsphereTypes()

IConvertAsphereType ZOSAPI.Tools.IOpticalSystemTools.OpenConvertAsphereTypes ( )

Opens the Convert Asphere Types tool.

Returns

◆ OpenConvertToNSCGroup()

IConvertToNSCGroup ZOSAPI.Tools.IOpticalSystemTools.OpenConvertToNSCGroup ( )

Opens the Convert to NSC Group tool.

Usage (see Example 14 for a full sample)

C#

// Convert file to Non-sequential mode
ZOSAPI.Tools.IConvertToNSCGroup convertNSmode = TheSystem.Tools.OpenConvertToNSCGroup();
convertNSmode.ConvertFileToNSC = true;
convertNSmode.RunAndWaitForCompletion();
convertNSmode.Close();
// Save the Non-sequential file to the Double Gauss folder
string fileNameNS = System.IO.Path.Combine(dirLoc, "Double Gauss (NS).zos");
TheSystem.SaveAs(fileNameNS);
Interfaces and methods for converting the sequential surfaces to a non-sequential group....
Definition: IConvertToNSCGroup.cs:29
bool RunAndWaitForCompletion()
Sames as calling Run followed by WaitForCompletion.
bool Close()
Closes this tool and frees up and associated resources.

C++

// Convert file to Non-sequential mode
ZOSAPI_Interfaces::IConvertToNSCGroupPtr convertNSmode = TheSystem->Tools->OpenConvertToNSCGroup();
convertNSmode->ConvertFileToNSC = true;
ZOSAPI_Interfaces::ISystemToolPtr baseTool2 = convertNSmode;
baseTool2->RunAndWaitForCompletion();
baseTool2->Close();
// Save the Non-sequential file to the Double Gauss folder
_bstr_t fileNameNS = dirLoc + (_bstr_t)"\\Double_Gauss_(NS).zos";
TheSystem->SaveAs(fileNameNS);

Matlab

% Convert file to Non-sequential mode
convertNSmode = TheSystem.Tools.OpenConvertToNSCGroup();
convertNSmode.ConvertFileToNSC = true;
convertNSmode.RunAndWaitForCompletion();
convertNSmode.Close();
% Save the Non-sequential file to the Double Gauss folder
fileNameNS = System.String.Concat(dirLoc, '\Double Gauss (NS).zos');
TheSystem.SaveAs(fileNameNS);

Python

# Convert file to Non-sequential mode
convertNSmode = TheSystem.Tools.OpenConvertToNSCGroup()
convertNSmode.ConvertFileToNSC = True
convertNSmode.RunAndWaitForCompletion()
convertNSmode.Close();
# Save the Non-sequential file to the Double Gauss folder
fileNameNS = dirLoc + "\\Double Gauss (NS).zos"
TheSystem.SaveAs(fileNameNS)
Returns

◆ OpenCreateProject()

ICreateProject ZOSAPI.Tools.IOpticalSystemTools.OpenCreateProject ( )

◆ OpenCreateZAR()

ICreateArchive ZOSAPI.Tools.IOpticalSystemTools.OpenCreateZAR ( )

Opens the Create Zemax Archive (ZAR) tool.

Returns

◆ OpenCriticalRaysetGenerator()

ICriticalRaysetGenerator ZOSAPI.Tools.IOpticalSystemTools.OpenCriticalRaysetGenerator ( )

Opens the critical rayset generator tool.

Returns

◆ OpenDesignLockdown()

IDesignLockdown ZOSAPI.Tools.IOpticalSystemTools.OpenDesignLockdown ( )

Opens the Design Lockdown tool.

Returns

◆ OpenExportCAD()

IExportCAD ZOSAPI.Tools.IOpticalSystemTools.OpenExportCAD ( )

Opens the Export to Cad tool.

Usage (see Example 20 for a full sample)

C#

// Get interface of IExportCAD
IExportCAD ToolExportCAD = TheSystem.Tools.OpenExportCAD();
Interfaces and methods for exporting the current system to various CAD formats. This interface can be...
Definition: Tools.cs:1104

C++

// Get interface of IExportCAD
IExportCADPtr ToolExportCAD = TheSystem->Tools->OpenExportCAD();

Matlab

% Get interface of IExportCAD
ToolExportCAD = TheSystem.Tools.OpenExportCAD();

Python

# Get interface of IExportCAD
ToolExportCAD = TheSystem.Tools.OpenExportCAD()
Returns

◆ OpenExportToSpeosLensSystem()

IExportToSpeosLensSystem ZOSAPI.Tools.IOpticalSystemTools.OpenExportToSpeosLensSystem ( )

◆ OpenExportToSpeosWhitebox()

IExportToSpeosWhitebox ZOSAPI.Tools.IOpticalSystemTools.OpenExportToSpeosWhitebox ( )

◆ OpenFileManager()

IFileManager ZOSAPI.Tools.IOpticalSystemTools.OpenFileManager ( )

◆ OpenFindBestAsphere()

IFindBestAsphere ZOSAPI.Tools.IOpticalSystemTools.OpenFindBestAsphere ( )

Opens the Find Best Asphere tool.

Returns

◆ OpenGlobalOptimization()

IGlobalOptimization ZOSAPI.Tools.IOpticalSystemTools.OpenGlobalOptimization ( )

Opens the Global Optimization tool.

Returns

◆ OpenGlobalOptimization_HPC()

IGlobalOptimization ZOSAPI.Tools.IOpticalSystemTools.OpenGlobalOptimization_HPC ( IHPCSettings  hpcSettings)

◆ OpenHammerOptimization()

IHammerOptimization ZOSAPI.Tools.IOpticalSystemTools.OpenHammerOptimization ( )

Opens the Hammer Optimization tool.

Usage (see Example 03 for a full sample)

C#

// Hammer for 10 seconds
Console.WriteLine("Running Hammer for 10 seconds");
IHammerOptimization HammerOpt = TheSystem.Tools.OpenHammerOptimization();
HammerOpt.RunAndWaitWithTimeout(10); // 10s of Hammer
HammerOpt.Cancel();
HammerOpt.WaitForCompletion();
HammerOpt.Close();
RunStatus RunAndWaitWithTimeout(double timeOutSeconds)
Starts the tool running, and waits for it to complete with the specified timeout value....
Interfaces and methods for running a Hammer Optimization. This interface can be accessed via the IOpt...
Definition: Optimization.cs:170

C++

// Hammer for 10 seconds
IHammerOptimizationPtr HammerOpt = TheSystem->Tools->OpenHammerOptimization();
baseTool = HammerOpt;
baseTool->RunAndWaitWithTimeout(10);
baseTool->Cancel();
baseTool->WaitForCompletion();
baseTool->Close();

Matlab

% Hammer for 10 seconds
HammerOpt = TheSystem.Tools.OpenHammerOptimization();
HammerOpt.RunAndWaitWithTimeout(10);
HammerOpt.Cancel();
HammerOpt.WaitForCompletion();
HammerOpt.Close();

Python

# Hammer for 10 seconds
# need to 'import time' at the top of the file to use the pause function
print('Running Hammer Optimization')
HammerOpt = TheSystem.Tools.OpenHammerOptimization()
HammerOpt.RunAndWaitWithTimeout(10)
HammerOpt.Cancel()
HammerOpt.WaitForCompletion()
HammerOpt.Close()
Returns

◆ OpenHammerOptimization_HPC()

IHammerOptimization ZOSAPI.Tools.IOpticalSystemTools.OpenHammerOptimization_HPC ( IHPCSettings  hpcSettings)

◆ OpenLensCatalogs()

ILensCatalogs ZOSAPI.Tools.IOpticalSystemTools.OpenLensCatalogs ( )

Opens the Lens Catalogs tool.

Returns

◆ OpenLightningTrace()

ILightningTrace ZOSAPI.Tools.IOpticalSystemTools.OpenLightningTrace ( )

Opens the Lightning Trace tool.

Returns

◆ OpenLocalOptimization()

ILocalOptimization ZOSAPI.Tools.IOpticalSystemTools.OpenLocalOptimization ( )

Opens the Local Optimization tool.

Usage (see Example 03 for a full sample)

C#

// Local optimisation till completion
ILocalOptimization LocalOpt = TheSystem.Tools.OpenLocalOptimization();
LocalOpt.Algorithm = OptimizationAlgorithm.DampedLeastSquares;
LocalOpt.Cycles = OptimizationCycles.Automatic;
LocalOpt.NumberOfCores = 8;
LocalOpt.Close();
Interfaces and methods for running a Local Optimization. This interface can be accessed via the IOpti...
Definition: Optimization.cs:50
OptimizationCycles
Definition: Optimization.cs:22
OptimizationAlgorithm
Definition: Optimization.cs:14

C++

// Local optimisation till completion
ILocalOptimizationPtr LocalOpt = TheSystem->Tools->OpenLocalOptimization();
LocalOpt->Algorithm = OptimizationAlgorithm_DampedLeastSquares;
LocalOpt->Cycles = OptimizationCycles_Automatic;
LocalOpt->NumberOfCores = 8;
ISystemToolPtr baseTool = LocalOpt;
baseTool->RunAndWaitForCompletion();
baseTool->Close();

Matlab

% Local optimisation till completion
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();
Definition: Optimization.cs:9

Python

# Local optimisation till completion
print('Running Local Optimization')
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()
Returns

◆ OpenMaterialsCatalog()

IMaterialsCatalog ZOSAPI.Tools.IOpticalSystemTools.OpenMaterialsCatalog ( )

◆ OpenMeritFunctionCalculator()

IMFCalculator ZOSAPI.Tools.IOpticalSystemTools.OpenMeritFunctionCalculator ( )

Opens the Merit Function Calculator tool.

Returns

◆ OpenNSCRayTrace()

INSCRayTrace ZOSAPI.Tools.IOpticalSystemTools.OpenNSCRayTrace ( )

Creates a new NSC Ray Trace instance. Note – only one instance of this tool can be open at a time. See the INSCRayTrace documentation for more information.

Usage (see Example 02 for a full sample)

C#

// Create ray trace
INSCRayTrace NSCRayTrace = TheSystem.Tools.OpenNSCRayTrace();
NSCRayTrace.SplitNSCRays = true;
NSCRayTrace.ScatterNSCRays = false;
NSCRayTrace.UsePolarization = true;
NSCRayTrace.IgnoreErrors = true;
NSCRayTrace.SaveRays = false;
// Run ray trace
NSCRayTrace.RunAndWaitForCompletion();
NSCRayTrace.Close();
Interfaces and methods for running a non-sequential ray trace. This interface can be accessed via the...
Definition: RayTrace.cs:45

C++

// Creat ray trace
INSCRayTracePtr NSCRayTrace = TheSystem->Tools->OpenNSCRayTrace();
NSCRayTrace->SplitNSCRays = true;
NSCRayTrace->ScatterNSCRays = false;
NSCRayTrace->UsePolarization = true;
NSCRayTrace->IgnoreErrors = true;
NSCRayTrace->SaveRays = false;
NSCRayTrace->ClearDetectors(0);
// Run ray trace
// Methods RunAndWaitForCompletion() and Close is in base interface ISystemTool.
// To use these two methods, cast to ISystemTool first.
ISystemToolPtr baseTool = NSCRayTrace;
baseTool->RunAndWaitForCompletion();
baseTool->Close();

Matlab

% Create ray trace
NSCRayTrace = TheSystem.Tools.OpenNSCRayTrace();
NSCRayTrace.SplitNSCRays = true;
NSCRayTrace.ScatterNSCRays = false;
NSCRayTrace.UsePolarization = true;
NSCRayTrace.IgnoreErrors = true;
NSCRayTrace.SaveRays = false;
NSCRayTrace.ClearDetectors(0);
% Run ray trace
NSCRayTrace.RunAndWaitForCompletion();
NSCRayTrace.Close();

Python

# Create ray trace
NSCRayTrace = TheSystem.Tools.OpenNSCRayTrace()
NSCRayTrace.SplitNSCRays = True
NSCRayTrace.ScatterNSCRays = False
NSCRayTrace.UsePolarization = True
NSCRayTrace.IgnoreErrors = True
NSCRayTrace.SaveRays = False
NSCRayTrace.Run()
Returns

◆ OpenNSCRayTrace_HPC()

INSCRayTrace ZOSAPI.Tools.IOpticalSystemTools.OpenNSCRayTrace_HPC ( IHPCSettings  hpcSettings)

◆ OpenProjectToFileConverter()

FileManager.IConvertProjectToFileTool ZOSAPI.Tools.IOpticalSystemTools.OpenProjectToFileConverter ( )

◆ OpenQuickAdjust()

IQuickAdjust ZOSAPI.Tools.IOpticalSystemTools.OpenQuickAdjust ( )

Opens the Quick Adjust tool.

Returns

◆ OpenQuickFocus()

IQuickFocus ZOSAPI.Tools.IOpticalSystemTools.OpenQuickFocus ( )

Opens the Quick Focus tool.

Usage (see Example 15 for a full sample)

C#

//change BFL & run quick focus
Surface_Last.Thickness = 40.0;
IQuickFocus QFocus = tools.OpenQuickFocus();
QFocus.Criterion = QuickFocusCriterion.SpotSizeRadial;
QFocus.UseCentroid = true;
QFocus.Close();
SampleFile = System.IO.Path.Combine(TheApplication.SamplesDir, @"API\CS\e15_Seq_Optimization\OptimizedFile2.zos");
TheSystem.SaveAs(SampleFile);
Interfaces and methods for running the Quick Focus tool. This interface can be accessed via the IOpti...
Definition: Tools.cs:793
QuickFocusCriterion
Definition: Tools.cs:767

C++

// change BFL & run quick focus
Surface_Last->Thickness = 40.0;
IQuickFocusPtr QFocus = tools->OpenQuickFocus();
QFocus->Criterion = QuickFocusCriterion::QuickFocusCriterion_SpotSizeRadial;
QFocus->UseCentroid = true;
ISystemToolPtr baseTool = QFocus;
baseTool->RunAndWaitForCompletion();
baseTool->Close();
SampleFile = _bstr_t(TheApplication->SamplesDir) + "\\API\\CPP\\e15_Seq_Optimization\\OptimizedFile2.zos";
TheSystem->SaveAs(SampleFile);

Matlab

%change BFL & run quick focus
Surface_Last.Thickness = 40.0;
QFocus = tools.OpenQuickFocus();
QFocus.Criterion = ZOSAPI.Tools.General.QuickFocusCriterion.SpotSizeRadial;
QFocus.UseCentroid = true;
QFocus.RunAndWaitForCompletion();
QFocus.Close();
SampleFile = System.String.Concat(TheApplication.SamplesDir, '\API\Matlab\e15_Seq_Optimization\OptimizedFile2.zos');
TheSystem.SaveAs(SampleFile);
Definition: Tools.cs:697

Python

# change BFL & run quick focus
Surface_Last.Thickness = 40.0
QFocus = tools.OpenQuickFocus()
QFocus.Criterion = ZOSAPI.Tools.General.QuickAdjustCriterion.SpotSizeRadial
QFocus.UseCentroid = True
QFocus.RunAndWaitForCompletion()
QFocus.Close()
SampleFile = TheApplication.SamplesDir + '\\API\\Python\\e15_Seq_Optimization\\OptimizedFile2.zos'
TheSystem.SaveAs(SampleFile)
Returns
Examples
CSharpStandalone_15_Seq_Optimization.cs.

◆ OpenQuickSensitivity()

IQuickSensitivity ZOSAPI.Tools.IOpticalSystemTools.OpenQuickSensitivity ( )

◆ OpenRayAimingWizard()

IRayAimingWizard ZOSAPI.Tools.IOpticalSystemTools.OpenRayAimingWizard ( )

◆ OpenRayDatabaseReader()

IZRDReader ZOSAPI.Tools.IOpticalSystemTools.OpenRayDatabaseReader ( )

◆ OpenRestoreProject()

IRestoreProject ZOSAPI.Tools.IOpticalSystemTools.OpenRestoreProject ( )

◆ OpenRestoreZAR()

IRestoreArchive ZOSAPI.Tools.IOpticalSystemTools.OpenRestoreZAR ( )

Opens the Restore Zemax Archive (ZAR) tool.

Returns

◆ OpenRMSSpotRadiusCalculator()

IComputeRMSSpotSize ZOSAPI.Tools.IOpticalSystemTools.OpenRMSSpotRadiusCalculator ( )

Opens the RMS spot radius calculator. Note that this is only valid in sequential mode.

Returns

◆ OpenScale()

IScale ZOSAPI.Tools.IOpticalSystemTools.OpenScale ( )

Opens the Scale Lens tool.

Usage (see Example 11 for a full sample)

C#

// Set system lens units to inches, scale all values with Scale Lens tool
// For demonstration only. This file is new, so it has default units mm.
ZemaxSystemUnits unit = TheSystemData.Units.LensUnits;
// Open Scale Lens tool
ScaleLens = TheSystem.Tools.OpenScale();
// Apply Tool Settings
ScaleLens.ScaleByUnits = true;
ScaleLens.ScaleToUnit = ScaleToUnits.Inches;
ScaleLens.RunAndWaitForCompletion();
ScaleLens.Close();
ZemaxSystemUnits
Definition: InterfacesSE.cs:27
ScaleToUnits
Definition: Tools.cs:1420

C++

// Set system lens units to inches, scale all values with Scale Lens tool
// For demonstration only. This file is new, so it has default units mm.
ZemaxSystemUnits unit = TheSystemData->Units->LensUnits;
// Open Scale Lens tool
IScalePtr ScaleLens = TheSystem->Tools->OpenScale();
// Apply Tool Settings
ScaleLens->ScaleByUnits = true;
ScaleLens->ScaleToUnit = ScaleToUnits_Inches;
ISystemToolPtr baseTool = ScaleLens;
baseTool->RunAndWaitForCompletion();
baseTool->Close();

Matlab

% Set system lens units to inches, scale all values with Scale Lens tool
unit = TheSystemData.Units.LensUnits; % For demonstration only. This file is new, so it has default units mm.
ScaleLens = TheSystem.Tools.OpenScale(); % Open Scale Lens tool
% Apply Tool Settings
ScaleLens.ScaleByUnits = true;
ScaleLens.ScaleToUnit = ZOSAPI.Tools.General.ScaleToUnits.Inches;
ScaleLens.RunAndWaitForCompletion();
ScaleLens.Close();

Python

# Set system lens units to inches, scale all values with Scale Lens tool
unit = TheSystemData.Units.LensUnits # For demonstration only. This file is new, so it has default units mm.
ScaleLens = TheSystem.Tools.OpenScale() # Open Scale Lens tool
# Apply Tool Settings
ScaleLens.ScaleByUnits = True
ScaleLens.ScaleToUnit = 2 # 0=millimeters; 1=centimeters; 2=inches; 3=meters
# Cast to ISystemTool interface to gain access to Run
ScaleLens.RunAndWaitForCompletion()
ScaleLens.Close()
Returns

◆ OpenShadedModelVisualizationExport()

IShadedModelVisualizationExport ZOSAPI.Tools.IOpticalSystemTools.OpenShadedModelVisualizationExport ( )

Opens the Shaded Model Visualization export tool. This tool allows retreieving a list of triangles representing the solid models used for Shaded Model visualization.

Returns

◆ OpenToleranceDataViewer()

IToleranceDataViewer ZOSAPI.Tools.IOpticalSystemTools.OpenToleranceDataViewer ( )

◆ OpenTolerancing()

ITolerancing ZOSAPI.Tools.IOpticalSystemTools.OpenTolerancing ( )

Opens the Tolerancing tool.

Usage (see Example 14 for a full sample)

C#

// Set up the Tolerancing analysis and run it
ZOSAPI.Tools.Tolerancing.ITolerancing tol = TheSystem.Tools.OpenTolerancing();
// Select Sensitivity mode
tol.SetupMode = ZOSAPI.Tools.Tolerancing.SetupModes.Sensitivity;
// Select Criterion and related settings
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;
// Select the number or MC runs and files to save
tol.NumberOfRuns = 20;
tol.NumberToSave = 20;
// Run the Tolerancing analysis
tol.Close();
Interfaces and methods for running Tolerancing. This interface can be accessed via the IOpticalSystem...
Definition: ITolerancing.cs:137
Definition: ITolerancing.cs:5

C++

// Set up the Tolerancing analysis and run it
ZOSAPI_Interfaces::ITolerancingPtr tol = TheSystem->Tools->OpenTolerancing();
// Select Sensitivity mode
tol->SetupMode = ZOSAPI_Interfaces::SetupModes_Sensitivity;
// Select Criterion and related settings
tol->Criterion = ZOSAPI_Interfaces::Criterions_RMSSpotRadius;
tol->CriterionSampling = 3;
tol->CriterionComp = ZOSAPI_Interfaces::CriterionComps_OptimizeAll_DLS;
tol->CriterionCycle = 2;
tol->CriterionField = ZOSAPI_Interfaces::CriterionFields_UserDefined;
// Select the number or MC runs and files to save
tol->NumberOfRuns = 20;
tol->NumberToSave = 20;
// Run the Tolerancing analysis
ZOSAPI_Interfaces::ISystemToolPtr baseTool = tol;
baseTool->RunAndWaitForCompletion();
baseTool->Close();

Matlab

% Set up the Tolerancing analysis and run it
tol = TheSystem.Tools.OpenTolerancing();
% Select Sensitivity mode
tol.SetupMode = ZOSAPI.Tools.Tolerancing.SetupModes.Sensitivity;
% Select Criterion and related settings
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;
% Select the number or MC runs and files to save
tol.NumberOfRuns = 20;
tol.NumberToSave = 20;
% Run the Tolerancing analysis
tol.RunAndWaitForCompletion();
tol.Close();

Python

# Set up Tolerancing analysis and run it
tol = TheSystem.Tools.OpenTolerancing()
# Select Sensitivity mode
tol.SetupMode = ZOSAPI.Tools.Tolerancing.SetupModes.Sensitivity
# Select Criterion and related settings
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
# Select number of MC runs and files to save
tol.NumberOfRuns = 20
tol.NumberToSave = 20
# Run the Tolerancing analysis
tol.RunAndWaitForCompletion()
tol.Close()
Returns

◆ OpenTolerancing_HPC()

ITolerancing ZOSAPI.Tools.IOpticalSystemTools.OpenTolerancing_HPC ( IHPCSettings  hpcSettings)

◆ RemoveAllVariables()

bool ZOSAPI.Tools.IOpticalSystemTools.RemoveAllVariables ( )

Removes all variables in the system.

Returns
Examples
CSharpStandalone_15_Seq_Optimization.cs.

◆ SetAllRadiiVariable()

int ZOSAPI.Tools.IOpticalSystemTools.SetAllRadiiVariable ( )

Makes all radii in the system variable.

Usage (see Example 15 for a full sample)

C#

//setup a few variables
tools.SetAllRadiiVariable();
ILDERow Surface1 = TheLDE.GetSurfaceAt(1);
ILDERow Surface2 = TheLDE.GetSurfaceAt(2);
ILDERow Surface5 = TheLDE.GetSurfaceAt(5);
ILDERow Surface6 = TheLDE.GetSurfaceAt(6);
ILDERow Surface9 = TheLDE.GetSurfaceAt(9);
ILDERow Surface10 = TheLDE.GetSurfaceAt(10);
ILDERow Surface11 = TheLDE.GetSurfaceAt(11);

C++

// setup a few variables
tools->SetAllRadiiVariable();
ILDERowPtr Surface1 = TheLDE->GetSurfaceAt(1);
ILDERowPtr Surface2 = TheLDE->GetSurfaceAt(2);
ILDERowPtr Surface5 = TheLDE->GetSurfaceAt(5);
ILDERowPtr Surface6 = TheLDE->GetSurfaceAt(6);
ILDERowPtr Surface9 = TheLDE->GetSurfaceAt(9);
ILDERowPtr Surface10 = TheLDE->GetSurfaceAt(10);
ILDERowPtr Surface11 = TheLDE->GetSurfaceAt(11);

Matlab

%setup a few variables
tools.SetAllRadiiVariable();
Surface1 = TheLDE.GetSurfaceAt(1);
Surface2 = TheLDE.GetSurfaceAt(2);
Surface5 = TheLDE.GetSurfaceAt(5);
Surface6 = TheLDE.GetSurfaceAt(6);
Surface9 = TheLDE.GetSurfaceAt(9);
Surface10 = TheLDE.GetSurfaceAt(10);
Surface11 = TheLDE.GetSurfaceAt(11);

Python

# setup a few variables
tools.SetAllRadiiVariable()
Surface1 = TheLDE.GetSurfaceAt(1)
Surface2 = TheLDE.GetSurfaceAt(2)
Surface5 = TheLDE.GetSurfaceAt(5)
Surface6 = TheLDE.GetSurfaceAt(6)
Surface9 = TheLDE.GetSurfaceAt(9)
Surface10 = TheLDE.GetSurfaceAt(10)
Surface11 = TheLDE.GetSurfaceAt(11)
Returns
Examples
CSharpStandalone_15_Seq_Optimization.cs.

◆ SetAllThicknessesVariable()

int ZOSAPI.Tools.IOpticalSystemTools.SetAllThicknessesVariable ( )

Makes all thicknesses in the system variable.

Returns

Property Documentation

◆ CurrentTool

ISystemTool ZOSAPI.Tools.IOpticalSystemTools.CurrentTool
get

Gets the currently open tool. Note that if a tool is already open, all attempts to open a new tool will fail.

The current tool if one is currently open; otherwise, null.

◆ IsRunning

bool ZOSAPI.Tools.IOpticalSystemTools.IsRunning
get

Gets a value indicating whether the CurrentTool is currently running asynchronously.

true if a tool is currently running; otherwise, false.

◆ LastError

IMessage ZOSAPI.Tools.IOpticalSystemTools.LastError
get

◆ Layouts

ILayouts ZOSAPI.Tools.IOpticalSystemTools.Layouts
get

◆ Progress

int ZOSAPI.Tools.IOpticalSystemTools.Progress
get

Gets the progress of the currently running tool, if the tool reports incremental progress.

The current progress percentage, if available.

◆ Status

string ZOSAPI.Tools.IOpticalSystemTools.Status
get

Gets the status of the currently running tool, if the tool reports incremental status messages.

The current status, if available.

Connect with Ansys