Skip to main content

ZOS-API interface 2024 R1

ZOSAPI.IZOSAPI_Application Interface Reference

Last update: 17.07.2025

This interface contains all information about the current ZOS-API connection, as well as methods for accessing an Optical System. This interface can only be retrieved from a connection interface - ZOSAPI.IZOSAPI_Connection for more information. More...

Public Member Functions

IOpticalSystem GetSystemAt (int pos)
 Gets the system at the specified index. Note that.
 
bool CloseSystemAt (int pos, bool saveIfNeeded)
 Closes the system at the specified index.
 
IOpticalSystem LoadNewSystem (String LensFile)
 Creates a new optical system, and loads the specified lens file.
 
IOpticalSystem CreateNewSystem (SystemType mode)
 Creates a new empty optical system, in the specified mode.
 
void UpdateFileLists ()
 Update the cached file lists. (For example, if you've saved a 'STEP' file, you'll need to call this function before trying to use that file later in your code.)
 
string GetDate ()
 This item extracts the current date and time, in the format selected by the user in the Zemax environment dialog box.
 
void CloseApplication ()
 Shut down the Optic Studio process.
 
void CheckForUpdates ()
 Populate the available updates status (see CheckForUpdatesStatus and CheckForUpdatesVersion).
 
void ClearMessageLog ()
 
bool BeginMessageLogging ()
 
bool EndMessageLogging ()
 
string RetrieveLogMessages ()
 
IZOSAPI_Callback LoadCCallback (string cLib, string callbackName, ISettingsData settings)
 
IMessage RegisterCOperandCallback (string cLib, string callbackName, ISettingsData settings)
 
IZOSAPI_Callback LoadNETCallback (string fromAssembly, string typeName, ISettingsData settings)
 
IMessage RegisterNETOperandCallback (string fromAssembly, string typeName, ISettingsData settings)
 
bool CopySettingsData (ISettingsData from, ISettingsData to)
 
ISettingsData CreateSettings ()
 
ISettingsData CreateSettingsFromParent (IZAPI_BaseObject parent)
 
IDataDictionary OpenDataFile (string fileName)
 
IDataDictionary CreateDataFile (string fileName, ZemaxFileTypes type, int data1, int data2)
 
string RunCommand (string command)
 For internal debugging purposes only.
 

Properties

LicenseStatusType LicenseStatus [get]
 Gets the license status. Note that this displays the license edition if successful, or an error code if unsucessful.
 
bool IsValidLicenseForAPI [get]
 Gets a value indicating whether this the API is currently useable.
 
string InitializationErrors [get]
 Gets the initialization errors (similar to InitializationErrorCode).
 
string InitializationErrorCode [get]
 Gets the initialization error code for debug purposes. This should only have a value when using IZOSAPI_Connection.CreateNewApplication, and LicenseStatus is one of the errro values.
 
ZOSAPI_Mode Mode [get]
 Gets the current connetion mode. Use this to check if Optic Studio is expecting a user operand / analysis / etc.
 
string SerialCode [get]
 
int OpticStudioVersion [get]
 
int ExpirationYear [get]
 
int ExpirationMonth [get]
 
int ExpirationDay [get]
 
int NumberOfOpticalSystems [get]
 Gets the current number of open optical systems. Note that there will always be at least one, the PrimarySystem.
 
IOpticalSystem PrimarySystem [get]
 Gets the primary system. When Mode is ZOSAPI_Mode.Server, this will initially be an empty sequential system. For ZOSAPI_Mode.Plugin this will be the live optical system. For all other modes, it will be a copy of the optical system.
 
int NumberOfCPUs [get]
 
string ProgramDir [get]
 Gets the Program directory (e.g. C:\Program Files\Zemax OpticStudio).
 
string LensDir [get]
 Gets the Lens directory (e.g. C:\Users\John.Doe\My Documents\Zemax\Samples). Note that this is the same as SamplesDir.
 
string ObjectsDir [get]
 Gets the Objects directory (e.g. C:\Users\John.Doe\My Documents\Zemax\OBJECTS).
 
string GlassDir [get]
 Gets the Glass directory (e.g. C:\Users\John.Doe\My Documents\Zemax\GLASSCAT).
 
string ZPLDir [get]
 Gets the ZPL macros directory (e.g. C:\Users\John.Doe\My Documents\Zemax\MACROS).
 
string CoatingDir [get]
 Gets the Coating directory (e.g. C:\Users\John.Doe\My Documents\Zemax\COATINGS).
 
string POPDir [get]
 Gets the POP directory (e.g. C:\Users\John.Doe\My Documents\Zemax\BEAMFILES).
 
string ImagesDir [get]
 Gets the Images directory (e.g. C:\Users\John.Doe\My Documents\Zemax\IMAFILES).
 
string SolidWorksFilesDir [get]
 Gets the SolidWorks files directory (e.g. C:\Users\John.Doe\My Documents\Zemax\OBJECTS\SolidWorks Files).
 
string AutodeskInventorFilesDir [get]
 Gets the Autodesk Inventor files directory (e.g. C:\Users\John.Doe\My Documents\Zemax\OBJECTS\Inventor Files).
 
string CreoParametricFilesDir [get]
 Gets the Creo Parametric files directory (e.g. C:\Users\John.Doe\My Documents\Zemax\OBJECTS\Creo Parametric Files).
 
string MATLABFilesDir [get]
 Gets the MATLAB directory (e.g. C:\Program Files\MATLAB).
 
string ScatterDir [get]
 Gets the Scatter directory (e.g. C:\Users\John.Doe\My Documents\Zemax\ScatterData).
 
string UndoDir [get]
 Gets the Undo directory (e.g. C:\Users\John.Doe\My Documents\Zemax\UNDO).
 
string SamplesDir [get]
 Gets the full path for the current user's samples directory (in the My Documents\Zemax\Samples\ folder by default).
 
string ZemaxDataDir [get]
 Gets the full path for the current user's Zemax directory (in the My Documents\Zemax\ folder by default).
 
IVectorData OperandResults [get]
 In Operand mode, used to set the output data.
 
double OperandArgument1 [get]
 Argument 1 - Hx.
 
double OperandArgument2 [get]
 Argument 2 - Hy.
 
double OperandArgument3 [get]
 Argument 3 - Px.
 
double OperandArgument4 [get]
 Argument 4 - Py.
 
IUserAnalysisData UserAnalysisData [get]
 Gets the interface used to configure a User Analysis. Note that this is only available when Mode is ZOSAPI_Mode.UserAnalysis or ZOSAPI_Mode.UserAnalysisSettings.
 
bool TerminateRequested [get]
 For a user analysis or extension, gets a value indicating if the user wishes to abort the calculation.
 
bool ShowChangesInUI [get, set]
 If the Mode is ZOSAPI_Mode.Plugin, gets or sets a value indicating whether or not changes to the PrimarySystem are displayed in the OpticStudio user interface.
 
string ProgressMessage [get, set]
 If the Mode is ZOSAPI_Mode.Plugin, this controls the status message displayed in the OpticStudio progress dialog.
 
double ProgressPercent [get, set]
 If the Mode is ZOSAPI_Mode.Plugin, this controls the progress percentage displayed in the OpticStudio progress dialog.
 
UpdateStatus CheckForUpdatesStatus [get]
 Gets the check for updates status.
 
string CheckForUpdatesData [get]
 Gets data about the newest available product.
 
int CheckForUpdatesVersion [get]
 
IPreferences Preferences [get]
 
bool IsLoggingMessages [get]
 
int ZOSMajorVersion [get]
 
int ZOSMinorVersion [get]
 
int ZOSSPVersion [get]
 
bool IsSubscriptionLicense [get]
 
bool IsSTARModuleEnabled [get]
 

Detailed Description

Member Function Documentation

◆ BeginMessageLogging()

bool ZOSAPI.IZOSAPI_Application.BeginMessageLogging ( )

◆ CheckForUpdates()

void ZOSAPI.IZOSAPI_Application.CheckForUpdates ( )

Populate the available updates status (see CheckForUpdatesStatus and CheckForUpdatesVersion).

◆ ClearMessageLog()

void ZOSAPI.IZOSAPI_Application.ClearMessageLog ( )

◆ CloseApplication()

◆ CloseSystemAt()

bool ZOSAPI.IZOSAPI_Application.CloseSystemAt ( int  pos,
bool  saveIfNeeded 
)

Closes the system at the specified index.

Parameters
posThe index for the desired system (
1
to NumberOfOpticalSystems-1).
saveIfNeededIf set to true, the system will be saved to lens file before saving; otherwise, any changes will be lost.
Returns
true
if the system was closed;
false
otherwise.

◆ CopySettingsData()

bool ZOSAPI.IZOSAPI_Application.CopySettingsData ( ISettingsData  from,
ISettingsData  to 
)

◆ CreateDataFile()

IDataDictionary ZOSAPI.IZOSAPI_Application.CreateDataFile ( string  fileName,
ZemaxFileTypes  type,
int  data1,
int  data2 
)

◆ CreateNewSystem()

IOpticalSystem ZOSAPI.IZOSAPI_Application.CreateNewSystem ( SystemType  mode)

Creates a new empty optical system, in the specified mode.

Usage (see Example 06 for a full sample)

C#

// Create new non- sequential file
// Set up primary optical system
TheSystem = TheApplication.CreateNewSystem(ZOSAPI.SystemType.NonSequential);
INonSeqEditor TheNCE = TheSystem.NCE as INonSeqEditor;
This interface defines all properties and methods needed to interact with the Non-Sequential Componen...
Definition: InterfacesNCE.cs:363
The ZOSAPI namespace contains classes for initially connecting to zemax. See also ZOSAPI_Connection,...
Definition: IAS_FieldCurvatureAndDistortion.cs:5

C++

// Create new non- sequential file
// Set up primary optical system
TheSystem = TheApplication->CreateNewSystem(SystemType_NonSequential);
INonSeqEditorPtr TheNCE = TheSystem->NCE;

Matlab

% Create new non-sequential file
TheSystem = TheApplication.CreateNewSystem(ZOSAPI.SystemType.NonSequential);
TheNCE = TheSystem.NCE;
SystemType
Definition: Interfaces.cs:26

Python

# Create new non-sequential file
TheSystem = TheApplication.CreateNewSystem(ZOSAPI.SystemType.NonSequential)
TheNCE = TheSystem.NCE
Parameters
modeThe mode, either SystemType.Sequential for a sequential system, or SystemType.NonSequential for a pure non-sequential file.
Returns
A new, empty IOpticalSystem.
Examples
CSharpStandalone_06_nsc_phase.cs, CSharpStandalone_09_NSC_CAD.cs, CSharpStandalone_24_nsc_detectors.cs, and CSharpStandalone_25_source_spectrum_diffraction_grating.cs.

◆ CreateSettings()

ISettingsData ZOSAPI.IZOSAPI_Application.CreateSettings ( )

◆ CreateSettingsFromParent()

ISettingsData ZOSAPI.IZOSAPI_Application.CreateSettingsFromParent ( IZAPI_BaseObject  parent)
Here is the caller graph for this function:

◆ EndMessageLogging()

bool ZOSAPI.IZOSAPI_Application.EndMessageLogging ( )

◆ GetDate()

string ZOSAPI.IZOSAPI_Application.GetDate ( )

This item extracts the current date and time, in the format selected by the user in the Zemax environment dialog box.

Returns
The formatted date/time

◆ GetSystemAt()

IOpticalSystem ZOSAPI.IZOSAPI_Application.GetSystemAt ( int  pos)

Gets the system at the specified index. Note that.

0 will always be the same as PrimarySystem.

Parameters
posThe index for the desired system (
0
to NumberOfOpticalSystems-1).
Returns

◆ LoadCCallback()

IZOSAPI_Callback ZOSAPI.IZOSAPI_Application.LoadCCallback ( string  cLib,
string  callbackName,
ISettingsData  settings 
)

◆ LoadNETCallback()

IZOSAPI_Callback ZOSAPI.IZOSAPI_Application.LoadNETCallback ( string  fromAssembly,
string  typeName,
ISettingsData  settings 
)
Here is the caller graph for this function:

◆ LoadNewSystem()

IOpticalSystem ZOSAPI.IZOSAPI_Application.LoadNewSystem ( String  LensFile)

Creates a new optical system, and loads the specified lens file.

Parameters
LensFileThe desired lens file (.ZMX file).
Returns
A new IOpticalSystem if the file was successfully loaded; otherwise,
null
.

◆ OpenDataFile()

IDataDictionary ZOSAPI.IZOSAPI_Application.OpenDataFile ( string  fileName)

◆ RegisterCOperandCallback()

IMessage ZOSAPI.IZOSAPI_Application.RegisterCOperandCallback ( string  cLib,
string  callbackName,
ISettingsData  settings 
)

◆ RegisterNETOperandCallback()

IMessage ZOSAPI.IZOSAPI_Application.RegisterNETOperandCallback ( string  fromAssembly,
string  typeName,
ISettingsData  settings 
)
Here is the caller graph for this function:

◆ RetrieveLogMessages()

string ZOSAPI.IZOSAPI_Application.RetrieveLogMessages ( )

◆ RunCommand()

string ZOSAPI.IZOSAPI_Application.RunCommand ( string  command)

For internal debugging purposes only.

Parameters
command
Returns
Here is the caller graph for this function:

◆ UpdateFileLists()

void ZOSAPI.IZOSAPI_Application.UpdateFileLists ( )

Update the cached file lists. (For example, if you've saved a 'STEP' file, you'll need to call this function before trying to use that file later in your code.)

Property Documentation

◆ AutodeskInventorFilesDir

string ZOSAPI.IZOSAPI_Application.AutodeskInventorFilesDir
get

Gets the Autodesk Inventor files directory (e.g. C:\Users\John.Doe\My Documents\Zemax\OBJECTS\Inventor Files).

The full path to the Autodesk Inventor files directory.

◆ CheckForUpdatesData

string ZOSAPI.IZOSAPI_Application.CheckForUpdatesData
get

Gets data about the newest available product.

The most recent product data.

◆ CheckForUpdatesStatus

UpdateStatus ZOSAPI.IZOSAPI_Application.CheckForUpdatesStatus
get

Gets the check for updates status.

The current status. Note that you must call CheckForUpdates to ensure the results are up-to-date.

◆ CheckForUpdatesVersion

int ZOSAPI.IZOSAPI_Application.CheckForUpdatesVersion
get

◆ CoatingDir

string ZOSAPI.IZOSAPI_Application.CoatingDir
get

Gets the Coating directory (e.g. C:\Users\John.Doe\My Documents\Zemax\COATINGS).

The full path to the Coating directory.

◆ CreoParametricFilesDir

string ZOSAPI.IZOSAPI_Application.CreoParametricFilesDir
get

Gets the Creo Parametric files directory (e.g. C:\Users\John.Doe\My Documents\Zemax\OBJECTS\Creo Parametric Files).

The full path to the Creo Parameteric files directory.

◆ ExpirationDay

int ZOSAPI.IZOSAPI_Application.ExpirationDay
get

◆ ExpirationMonth

int ZOSAPI.IZOSAPI_Application.ExpirationMonth
get

◆ ExpirationYear

int ZOSAPI.IZOSAPI_Application.ExpirationYear
get

◆ GlassDir

string ZOSAPI.IZOSAPI_Application.GlassDir
get

Gets the Glass directory (e.g. C:\Users\John.Doe\My Documents\Zemax\GLASSCAT).

The full path to the Glass directory.

◆ ImagesDir

string ZOSAPI.IZOSAPI_Application.ImagesDir
get

Gets the Images directory (e.g. C:\Users\John.Doe\My Documents\Zemax\IMAFILES).

The full path to the Images directory.

◆ InitializationErrorCode

string ZOSAPI.IZOSAPI_Application.InitializationErrorCode
get

Gets the initialization error code for debug purposes. This should only have a value when using IZOSAPI_Connection.CreateNewApplication, and LicenseStatus is one of the errro values.

The initialization error code.

◆ InitializationErrors

string ZOSAPI.IZOSAPI_Application.InitializationErrors
get

Gets the initialization errors (similar to InitializationErrorCode).

The initialization errors.

◆ IsLoggingMessages

bool ZOSAPI.IZOSAPI_Application.IsLoggingMessages
get

◆ IsSTARModuleEnabled

bool ZOSAPI.IZOSAPI_Application.IsSTARModuleEnabled
get

◆ IsSubscriptionLicense

bool ZOSAPI.IZOSAPI_Application.IsSubscriptionLicense
get

◆ IsValidLicenseForAPI

◆ LensDir

string ZOSAPI.IZOSAPI_Application.LensDir
get

Gets the Lens directory (e.g. C:\Users\John.Doe\My Documents\Zemax\Samples). Note that this is the same as SamplesDir.

The full path to the Lens directory.

◆ LicenseStatus

LicenseStatusType ZOSAPI.IZOSAPI_Application.LicenseStatus
get

Gets the license status. Note that this displays the license edition if successful, or an error code if unsucessful.

Usage (see Example 10 for a full sample)

C#

// Save Ray Path Analysis to Text File
if (TheApplication.LicenseStatus == ZOSAPI.LicenseStatusType.PremiumEdition)
{
IA_ RayPath = TheSystem.Analyses.New_Analysis(AnalysisIDM.PathAnalysis);
RayPath_settings.RayDatabaseFile = "e10_API_RayTrace.ZRD";
RayPath.ApplyAndWaitForCompletion();
IAR_ Rays = RayPath.GetResults();
Rays.GetTextFile(TheApplication.SamplesDir + "\\API\\CS\\e10_RayPathAnalysis.txt");
}
else
{
Console.Write("\nThe RayPathAnalysis is a premium feature only\n\nPress any key to continue\n");
Console.ReadKey();
}
Base interface for all analysis windows. This interface can be accessed via the I_Analyses interface.
Definition: IA_Base.cs:29
Definition: IAS_PathAnalysis.cs:40
Definition: IAS_PathAnalysis.cs:10
Definition: IAS_FieldCurvatureAndDistortion.cs:5
AnalysisIDM
All available analysis types. See the I_Analyses interface for more information.
Definition: I_Analyses.cs:15

C++

// Save Ray Path Analysis to Text File
if (TheApplication->LicenseStatus == ZOSAPI_Interfaces::LicenseStatusType::LicenseStatusType_PremiumEdition) {
IA_Ptr RayPath = TheSystem->Analyses->New_Analysis(AnalysisIDM_PathAnalysis);
ZOSAPI_Interfaces::IAS_PathAnalysisPtr RayPath_settings = RayPath->GetSettings();
RayPath_settings->RayDatabaseFile = "e10_API_RayTrace.ZRD";
RayPath->ApplyAndWaitForCompletion();
IAR_Ptr Rays = RayPath->GetResults();
Rays->GetTextFile(TheApplication->SamplesDir + "\\API\\CPP\\e10_RayPathAnalysis.txt");
}

Matlab

% Save Ray Path Analysis to Text File
if TheApplication.LicenseStatus == ZOSAPI.LicenseStatusType.PremiumEdition
RayPath = TheSystem.Analyses.New_Analysis(ZOSAPI.Analysis.AnalysisIDM.PathAnalysis);
RayPath_settings = RayPath.GetSettings();
RayPath_settings.RayDatabaseFile = 'e10_API_Raytrace.ZRD';
RayPath.ApplyAndWaitForCompletion();
Rays = RayPath.GetResults();
Rays.GetTextFile(System.String.Concat(TheApplication.SamplesDir, '\API\Matlab\e10_RayPathAnalysis.txt'));
else
fprintf('\nThe RayPathAnalysis is a premium feature only\n');
end

Python

# Save Ray Path Analysis to Text File
if (TheApplication.LicenseStatus == ZOSAPI.LicenseStatusType.PremiumEdition):
# there is a bug in ZOS16.5 SP4 with COM; need to use ZOS16.5 SP5 or higher to run this code successfully
RayPath = TheSystem.Analyses.New_Analysis(ZOSAPI.Analysis.AnalysisIDM.PathAnalysis)
RayPath_settings = RayPath.GetSettings()
zrd = "e10_API_RayTrace.ZRD"
RayPath_settings.RayDatabaseFile = zrd
RayPath.ApplyAndWaitForCompletion()
Rays = RayPath.GetResults()
Rays.GetTextFile(TheApplication.SamplesDir + "\\API\\Python\\e10_RayPathAnalysis.txt")

The license status.

Examples
CSharpStandalone_01_new_file_and_quickfocus.cs, CSharpStandalone_02_NSC_ray_trace.cs, CSharpStandalone_03_open_file_and_optimise.cs, CSharpStandalone_04_pull_data_from_FFTMTF.cs, CSharpStandalone_05_Read_ZRD_File.cs, CSharpStandalone_06_nsc_phase.cs, CSharpStandalone_07_TiltDecenterAndMFOperand.cs, CSharpStandalone_08_NSCEDetectorData.cs, CSharpStandalone_09_NSC_CAD.cs, CSharpStandalone_10_NSC_ZRD_filter_string.cs, CSharpStandalone_11_Basic_Seq.cs, CSharpStandalone_12_Seq_SystemExplorer.cs, CSharpStandalone_14_Seq_Tolerance.cs, CSharpStandalone_15_Seq_Optimization.cs, CSharpStandalone_17_NSC_BulkScatter.cs, CSharpStandalone_18_SetMulticonfiguration.cs, CSharpStandalone_19_Surface_Properties.cs, CSharpStandalone_20_export_CAD_File.cs, CSharpStandalone_21_White_LED_Phosphor.cs, CSharpStandalone_22_seq_spot_diagram.cs, CSharpStandalone_23_ray_fan_native_manual_comparison.cs, CSharpStandalone_24_nsc_detectors.cs, CSharpStandalone_25_source_spectrum_diffraction_grating.cs, CSharpStandalone_26_modify_opticstudio_preferences.cs, and CSharpUserOperand_16_SumAbsoluteThickness.cs.

◆ MATLABFilesDir

string ZOSAPI.IZOSAPI_Application.MATLABFilesDir
get

Gets the MATLAB directory (e.g. C:\Program Files\MATLAB).

The full path to the MATLAB directory.

◆ Mode

◆ NumberOfCPUs

int ZOSAPI.IZOSAPI_Application.NumberOfCPUs
get

◆ NumberOfOpticalSystems

int ZOSAPI.IZOSAPI_Application.NumberOfOpticalSystems
get

Gets the current number of open optical systems. Note that there will always be at least one, the PrimarySystem.

The number of optical systems.

◆ ObjectsDir

string ZOSAPI.IZOSAPI_Application.ObjectsDir
get

Gets the Objects directory (e.g. C:\Users\John.Doe\My Documents\Zemax\OBJECTS).

Usage (see Example 09 for a full sample)

C#

// Insert CAD object
INonSeqEditor NSCE = TheSystem.NCE;
INCERow Obj1 = NSCE.GetObjectAt(1);
Obj1.ZPosition = -5;
// Set object 1 as CAD object if CAD file exists in proper directory
if (System.IO.File.Exists(TheApplication.ObjectsDir + "\\CAD Files\\ExtPoly.stp")) // Check if the CAD part exists in correct directory
{
IObjectTypeSettings Obj1_Type = Obj1.GetObjectTypeSettings(ObjectType.CADPartSTEPIGESSAT); // create CAD object type
Obj1_Type.FileName1 = "ExtPoly.stp"; // set CAD file to be used (file must be in directory specified under OpticStudio Preferences...Folders...Objects)
Obj1.ChangeType(Obj1_Type); // Set Object 1 as the previously specified CAD file
}
else
Console.WriteLine("CAD file not found");
All data for a Non-Sequential Component Editor object. This interface can be accessed via the INonSeq...
Definition: InterfacesNCE.cs:1198
This interface is used for selecting any files required by a object, and for changing object types....
Definition: InterfacesNCE.cs:1110
ObjectType
All supported non-sequential object types.
Definition: InterfacesNCE.cs:38

C++

// Insert CAD object
INonSeqEditorPtr NSCE = TheSystem->NCE;
INCERowPtr Obj1 = NSCE->GetObjectAt(1);
Obj1->ZPosition = -5;
// Define the STP file to search for.
std::ifstream ifile((string)TheApplication->ObjectsDir + "\\CAD Files\\ExtPoly.stp");
if (ifile) // Check if the CAD part exists in correct directory. Directory is defined under OpticStudio Preferences...Folders...Objects.
{
IObjectTypeSettingsPtr Obj1_Type = Obj1->GetObjectTypeSettings(ObjectType_CADPartSTEPIGESSAT); // create CAD object type
Obj1_Type->FileName1 = "ExtPoly.stp"; // set CAD file to be used (file must be in valid directory)
Obj1->ChangeType(Obj1_Type); // Set Object 1 as the previously specified CAD file
}
else
cout << "CAD file not found" << endl;

Matlab

% Insert CAD object
NSCE = TheSystem.NCE;
Obj1 = NSCE.GetObjectAt(1);
Obj1.ZPosition = -5;
Obj1_Type = Obj1.GetObjectTypeSettings(ZOSAPI.Editors.NCE.ObjectType.CADPartSTEPIGESSAT); % create CAD object type
% Set object 1 as ExtPoly.stp if CAD file exists in proper directory
% (directory is defined in OpticStudio Preferences...Folders...Objects)
if exist(char(System.String.Concat(TheApplication.ObjectsDir, '\\CAD Files\\ExtPoly.stp')), 'file') % Check if the CAD part exists in correct directory
Obj1_Type.FileName1 = 'ExtPoly.stp'; % set CAD file to be used (file must be in valid directory)
Obj1.ChangeType(Obj1_Type); % Set Object 1 as the previously specified CAD file
else
HandleError('ImportError("CAD file not found")');
end
Definition: InterfacesNCE.cs:19
Definition: InterfacesEditors.cs:12

Python

# Insert CAD object
NSCE = TheSystem.NCE
Obj1 = NSCE.GetObjectAt(1)
Obj1.ZPosition = -5
Obj1_Type = Obj1.GetObjectTypeSettings(ZOSAPI.Editors.NCE.ObjectType.CADPartSTEPIGESSAT) # create CAD object type
# Set object 1 as ExtPoly.stp if it exists in proper directory. The directory is defined under OpticStudio Preferences...Folders...Objects
if os.path.isfile(TheApplication.ObjectsDir + "\\CAD Files\\ExtPoly.stp"): # Check if the CAD part exists in correct directory
Obj1_Type.FileName1 = 'ExtPoly.stp' # set CAD file to be used (file must be in valid directory)
Obj1.ChangeType(Obj1_Type) # Set Object 1 as the previously specified CAD file
else:
raise ImportError("CAD file not found")

The full path to the Objects directory.

Examples
CSharpStandalone_09_NSC_CAD.cs.

◆ OperandArgument1

double ZOSAPI.IZOSAPI_Application.OperandArgument1
get

Argument 1 - Hx.

Usage (see Example 16 for a full sample)

C#

// Read the operand arguments (Note that we aren't using operand 3 and 4)
int surf1 = (int)TheApplication.OperandArgument1;
int surf2 = (int)TheApplication.OperandArgument2;
//double x = TheApplication.OperandArgument3;
//double y = TheApplication.OperandArgument4;

C++

// Read the operand arguments (Note that we aren't using operand 3 and 4)
int surf1 = (int)TheApplication->OperandArgument1;
int surf2 = (int)TheApplication->OperandArgument2;
//double x = (double)TheApplication->OperandArgument3;
//double y = (double)TheApplication->OperandArgument4;
Examples
CSharpUserOperand_16_SumAbsoluteThickness.cs.

◆ OperandArgument2

double ZOSAPI.IZOSAPI_Application.OperandArgument2
get

Argument 2 - Hy.

Usage (see Example 16 for a full sample)

C#

// Read the operand arguments (Note that we aren't using operand 3 and 4)
int surf1 = (int)TheApplication.OperandArgument1;
int surf2 = (int)TheApplication.OperandArgument2;
//double x = TheApplication.OperandArgument3;
//double y = TheApplication.OperandArgument4;

C++

// Read the operand arguments (Note that we aren't using operand 3 and 4)
int surf1 = (int)TheApplication->OperandArgument1;
int surf2 = (int)TheApplication->OperandArgument2;
//double x = (double)TheApplication->OperandArgument3;
//double y = (double)TheApplication->OperandArgument4;
Examples
CSharpUserOperand_16_SumAbsoluteThickness.cs.

◆ OperandArgument3

double ZOSAPI.IZOSAPI_Application.OperandArgument3
get

◆ OperandArgument4

double ZOSAPI.IZOSAPI_Application.OperandArgument4
get

◆ OperandResults

IVectorData ZOSAPI.IZOSAPI_Application.OperandResults
get

In Operand mode, used to set the output data.

Usage (see Example 16 for a full sample)

C#

//Make the sum of the absolute value of each surface thickness
double thic = 0;
if (surf1 <= surf2)
{
for (int i = surf1; i <= surf2; i++)
{
surf = TheSystem.LDE.GetSurfaceAt(i);
thic = thic + Math.Abs(surf.Thickness);
}
operandResults[0] = thic;
}
else
{
operandResults[0] = 1e9; // invalid input
}
All data for a Lens Data Editor surface. This interface can be accessed via the ILensDataEditor inter...
Definition: InterfacesLDE.cs:791
double Thickness
Gets or sets the surface thickness.
Definition: InterfacesLDE.cs:1009

C++

//Make the sum of the absolute value of each surface thickness
ILDERowPtr surf;
double thic = 0;
if (surf1 <= surf2)
{
for (int i = surf1; i <= surf2; i++)
{
surf = TheSystem->LDE->GetSurfaceAt(i);
thic = thic + abs(surf->Thickness);
}
operandResults[0] = thic;
}
else
{
operandResults[0] = 1e9; // invalid input
}
Examples
CSharpUserOperand_16_SumAbsoluteThickness.cs.

◆ OpticStudioVersion

int ZOSAPI.IZOSAPI_Application.OpticStudioVersion
get

◆ POPDir

string ZOSAPI.IZOSAPI_Application.POPDir
get

Gets the POP directory (e.g. C:\Users\John.Doe\My Documents\Zemax\BEAMFILES).

The full path to the POP directory.

◆ Preferences

IPreferences ZOSAPI.IZOSAPI_Application.Preferences
get

◆ PrimarySystem

◆ ProgramDir

string ZOSAPI.IZOSAPI_Application.ProgramDir
get

Gets the Program directory (e.g. C:\Program Files\Zemax OpticStudio).

The full path to the Program directory.

◆ ProgressMessage

string ZOSAPI.IZOSAPI_Application.ProgressMessage
getset

If the Mode is ZOSAPI_Mode.Plugin, this controls the status message displayed in the OpticStudio progress dialog.

The progress message to display.

◆ ProgressPercent

double ZOSAPI.IZOSAPI_Application.ProgressPercent
getset

If the Mode is ZOSAPI_Mode.Plugin, this controls the progress percentage displayed in the OpticStudio progress dialog.

The progress message to display (0-100).

◆ SamplesDir

string ZOSAPI.IZOSAPI_Application.SamplesDir
get

Gets the full path for the current user's samples directory (in the My Documents\Zemax\Samples\ folder by default).

Usage (see Example 14 for a full sample)

C#

// Open Double Gauss sample file
string samplesFolder = TheApplication.SamplesDir;
string DGfile = System.IO.Path.Combine(samplesFolder, "Sequential\\Objectives\\Double Gauss 28 degree field.zos");
TheSystem.LoadFile(DGfile, false);

C++

// Open Double Gauss sample file
_bstr_t samplesFolder = TheApplication->SamplesDir;
_bstr_t DGfile = samplesFolder + (_bstr_t)"\\Sequential\\Objectives\\Double Gauss 28 degree field.zos";
TheSystem->LoadFile(DGfile, false);

Matlab

% Open Double Gauss sample file
samplesFolder = TheApplication.SamplesDir;
DGfile = System.String.Concat(samplesFolder, '\Sequential\Objectives\Double Gauss 28 degree field.zos');
TheSystem.LoadFile(DGfile, false);

Python

# Open Double Gauss sample file
samplesFolder = TheApplication.SamplesDir
DGfile = samplesFolder + r"\Sequential\Objectives\Double Gauss 28 degree field.zos"
TheSystem.LoadFile(DGfile, False)

n The full path of the samples directory.

Examples
CSharpStandalone_01_new_file_and_quickfocus.cs, CSharpStandalone_02_NSC_ray_trace.cs, CSharpStandalone_03_open_file_and_optimise.cs, CSharpStandalone_04_pull_data_from_FFTMTF.cs, CSharpStandalone_05_Read_ZRD_File.cs, CSharpStandalone_06_nsc_phase.cs, CSharpStandalone_08_NSCEDetectorData.cs, CSharpStandalone_09_NSC_CAD.cs, CSharpStandalone_10_NSC_ZRD_filter_string.cs, CSharpStandalone_11_Basic_Seq.cs, CSharpStandalone_12_Seq_SystemExplorer.cs, CSharpStandalone_14_Seq_Tolerance.cs, CSharpStandalone_15_Seq_Optimization.cs, CSharpStandalone_17_NSC_BulkScatter.cs, CSharpStandalone_18_SetMulticonfiguration.cs, CSharpStandalone_19_Surface_Properties.cs, CSharpStandalone_20_export_CAD_File.cs, CSharpStandalone_21_White_LED_Phosphor.cs, CSharpStandalone_22_seq_spot_diagram.cs, CSharpStandalone_23_ray_fan_native_manual_comparison.cs, CSharpStandalone_24_nsc_detectors.cs, and CSharpStandalone_25_source_spectrum_diffraction_grating.cs.

◆ ScatterDir

string ZOSAPI.IZOSAPI_Application.ScatterDir
get

Gets the Scatter directory (e.g. C:\Users\John.Doe\My Documents\Zemax\ScatterData).

The full path to the Scatter directory.

◆ SerialCode

string ZOSAPI.IZOSAPI_Application.SerialCode
get

◆ ShowChangesInUI

bool ZOSAPI.IZOSAPI_Application.ShowChangesInUI
getset

If the Mode is ZOSAPI_Mode.Plugin, gets or sets a value indicating whether or not changes to the PrimarySystem are displayed in the OpticStudio user interface.

true if changes are displayed; otherwise, false.

◆ SolidWorksFilesDir

string ZOSAPI.IZOSAPI_Application.SolidWorksFilesDir
get

Gets the SolidWorks files directory (e.g. C:\Users\John.Doe\My Documents\Zemax\OBJECTS\SolidWorks Files).

The full path to the SolidWorks files directory.

◆ TerminateRequested

bool ZOSAPI.IZOSAPI_Application.TerminateRequested
get

For a user analysis or extension, gets a value indicating if the user wishes to abort the calculation.

true if the use requsted terminations; otherwise, false.

◆ UndoDir

string ZOSAPI.IZOSAPI_Application.UndoDir
get

Gets the Undo directory (e.g. C:\Users\John.Doe\My Documents\Zemax\UNDO).

The full path to the Undo directory.

◆ UserAnalysisData

IUserAnalysisData ZOSAPI.IZOSAPI_Application.UserAnalysisData
get

Gets the interface used to configure a User Analysis. Note that this is only available when Mode is ZOSAPI_Mode.UserAnalysis or ZOSAPI_Mode.UserAnalysisSettings.

The user analysis data.

◆ ZemaxDataDir

string ZOSAPI.IZOSAPI_Application.ZemaxDataDir
get

Gets the full path for the current user's Zemax directory (in the My Documents\Zemax\ folder by default).

Usage (see Example 11 for a full sample)

C#

// Open Universal Plot of RMS Spot Size vs Surface3 Thickness
IA_ UnivPlot = TheSystem.Analyses.New_Analysis(AnalysisIDM.UniversalPlot1D);
IAS_ UnivPlot_Settings = UnivPlot.GetSettings();
Console.WriteLine("Universal Plot has analysis specific settings? " + UnivPlot.HasAnalysisSpecificSettings.ToString());
// Above is False; Universal Plot Settings must be changed via ModifySettings (changing a config (.cfg) file)
String cfg = TheApplication.ZemaxDataDir + "\\Configs\\UNI.CFG";
UnivPlot_Settings.Save(); // Create new .cfg file, named "UNI.CFG" in \Configs\ folder
UnivPlot_Settings.ModifySettings(cfg, "UN1_SURFACE", (TheSystem.LDE.NumberOfSurfaces - 2).ToString());
UnivPlot_Settings.ModifySettings(cfg, "UN1_STARTVAL", (Surf_4.Thickness - 0.4 / 25.4).ToString()); // Change universal plot settings
UnivPlot_Settings.ModifySettings(cfg, "UN1_STOPVAL", (Surf_4.Thickness + 0.1 / 25.4).ToString());
UnivPlot_Settings.ModifySettings(cfg, "UN1_STEPS", 20.ToString());
UnivPlot_Settings.ModifySettings(cfg, "UN1_PAR1", 10.ToString());
UnivPlot_Settings.ModifySettings(cfg, "UN1_OPERAND", "RSRE");
// For ModifySettings keycodes (UN1_STARTVAL, UN1_STEPS, etc.), see MODIFYSETTINGS page in ZPL>keywords help files
// LoadFrom allows you to load any CFG file, not just default; not available via GUI
UnivPlot_Settings.LoadFrom(cfg);
IAS_ GetSettings()
Gets the settings for the current analysis.

C++

// Open Universal Plot of RMS Spot Size vs Surface3 Thickness
IA_Ptr UnivPlot = TheSystem->Analyses->New_Analysis(AnalysisIDM_UniversalPlot1D);
IAS_Ptr UnivPlot_Settings = UnivPlot->GetSettings();
cout << "Universal Plot has analysis specific settings? " << UnivPlot->HasAnalysisSpecificSettings << endl;
// Above is False; Universal Plot Settings must be changed via ModifySettings (changing a config (.cfg) file)
_bstr_t cfg = TheApplication->ZemaxDataDir + "\\Configs\\UNI.CFG";
UnivPlot_Settings->Save(); // Create new .cfg file, named "UNI.CFG" in \Configs\ folder
UnivPlot_Settings->ModifySettings(cfg, "UN1_SURFACE", _bstr_t(TheSystem->LDE->NumberOfSurfaces - 2));
UnivPlot_Settings->ModifySettings(cfg, "UN1_STARTVAL", _bstr_t(Surf_4->Thickness - 0.4 / 25.4)); // Change universal plot settings
UnivPlot_Settings->ModifySettings(cfg, "UN1_STOPVAL", _bstr_t(Surf_4->Thickness + 0.1 / 25.4));
UnivPlot_Settings->ModifySettings(cfg, "UN1_STEPS", _bstr_t(20));
UnivPlot_Settings->ModifySettings(cfg, "UN1_PAR1", _bstr_t(10));
UnivPlot_Settings->ModifySettings(cfg, "UN1_OPERAND", "RSRE");
// For ModifySettings keycodes (UN1_STARTVAL, UN1_STEPS, etc.), see MODIFYSETTINGS page in ZPL>keywords help files
// LoadFrom allows you to load any CFG file, not just default; not available via GUI
UnivPlot_Settings->LoadFrom(cfg);

Matlab

% Open Universal Plot of RMS Spot Size vs Surface3 Thickness
UnivPlot = TheSystem.Analyses.New_Analysis(ZOSAPI.Analysis.AnalysisIDM.UniversalPlot1D);
UnivPlot_Settings = UnivPlot.GetSettings();
fprintf('Universal Plot has analysis specific settings? %i\n', UnivPlot.HasAnalysisSpecificSettings)
% Above is False; Universal Plot Settings must be changed via ModifySettings (changing a config (.cfg) file)
cfg = System.String.Concat(TheApplication.ZemaxDataDir, '\Configs\UNI.CFG');
UnivPlot_Settings.Save(); % Create new .cfg file, named "UNI.CFG" in \Configs\ folder
UnivPlot_Settings.ModifySettings(cfg, 'UN1_SURFACE', num2str(TheSystem.LDE.NumberOfSurfaces() - 2));
UnivPlot_Settings.ModifySettings(cfg, 'UN1_STARTVAL', num2str(Surf_4.Thickness - 0.4 / 25.4)); % Change universal plot settings
UnivPlot_Settings.ModifySettings(cfg, 'UN1_STOPVAL', num2str(Surf_4.Thickness + 0.1 / 25.4));
UnivPlot_Settings.ModifySettings(cfg, 'UN1_STEPS', num2str(20));
UnivPlot_Settings.ModifySettings(cfg, 'UN1_PAR1', num2str(10));
UnivPlot_Settings.ModifySettings(cfg, 'UN1_OPERAND', 'RSRE');
% For ModifySettings keycodes (UN1_STARTVAL, UN1_STEPS, etc.), see MODIFYSETTINGS page in ZPL>keywords help files
% LoadFrom allows you to load any CFG file, not just default; not available via GUI
UnivPlot_Settings.LoadFrom(cfg); % Load in the Universal Plot Settings

Python

# Open Universal Plot of RMS Spot Size vs Surface3 Thickness
UnivPlot = TheSystem.Analyses.New_Analysis(ZOSAPI.Analysis.AnalysisIDM.UniversalPlot1D)
UnivPlot_Settings = UnivPlot.GetSettings()
print("Universal Plot has analysis specific settings? ", UnivPlot.HasAnalysisSpecificSettings)
# Above is False; Universal Plot Settings must be changed via ModifySettings (changing a config (.cfg) file)
cfg = TheApplication.ZemaxDataDir + "\\Configs\\UNI.CFG"
UnivPlot_Settings.Save() # Create new .cfg file, named "UNI.CFG" in \Configs\ folder
UnivPlot_Settings.ModifySettings(cfg, 'UN1_SURFACE', str(TheSystem.LDE.NumberOfSurfaces - 2))
UnivPlot_Settings.ModifySettings(cfg, 'UN1_STARTVAL', str(Surf_4.Thickness - 0.4 / 25.4)) # Change universal plot settings
UnivPlot_Settings.ModifySettings(cfg, 'UN1_STOPVAL', str(Surf_4.Thickness + 0.1 / 25.4))
UnivPlot_Settings.ModifySettings(cfg, 'UN1_STEPS', str(20))
UnivPlot_Settings.ModifySettings(cfg, 'UN1_PAR1', str(10))
UnivPlot_Settings.ModifySettings(cfg, 'UN1_OPERAND', "RSRE")
# For ModifySettings keycodes (UN1_STARTVAL, UN1_STEPS, etc.), see MODIFYSETTINGS page in ZPL>keywords help files
# LoadFrom allows you to load any CFG file, not just default; not available via GUI
UnivPlot_Settings.LoadFrom(cfg)

The full path of the Zemax directory.

Examples
CSharpStandalone_08_NSCEDetectorData.cs.

◆ ZOSMajorVersion

int ZOSAPI.IZOSAPI_Application.ZOSMajorVersion
get

◆ ZOSMinorVersion

int ZOSAPI.IZOSAPI_Application.ZOSMinorVersion
get

◆ ZOSSPVersion

int ZOSAPI.IZOSAPI_Application.ZOSSPVersion
get

◆ ZPLDir

string ZOSAPI.IZOSAPI_Application.ZPLDir
get

Gets the ZPL macros directory (e.g. C:\Users\John.Doe\My Documents\Zemax\MACROS).

The full path to the ZPL directory.

Connect with Ansys