Skip to main content

Zemax OpticStudio ZOS-API 2026 R1

Namespace ZOSAPI

Last update: 13.03.2026

Definition:

The ZOSAPI namespace contains classes for initially connecting to zemax. See also ZOSAPI_Connection, and IZOSAPI_Application for more information.

Child namespaces

Classes

Enumeration types

Enumeration type SystemType

Definition:

enum SystemType {
  Sequential,
  NonSequential
}

Enumerator Sequential

Enumerator NonSequential

Enumeration type LicenseStatusType

Definition:

enum LicenseStatusType {
  Unknown = 0,
  KeyNotWorking,
  NewLicenseNeeded,
  StandardEdition,
  ProfessionalEdition,
  PremiumEdition,
  TooManyInstances,
  NotAuthorized,
  KeyNotFound,
  KeyExpired,
  Timeout,
  InstanceConflict,
  OpticsViewer,
  OpticStudioHPCEdition,
  EnterpriseEdition,
  StudentEdition
}

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);
                ZOSAPI.Analysis.RayTracing.IAS_PathAnalysis RayPath_settings = RayPath.GetSettings() as ZOSAPI.Analysis.RayTracing.IAS_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();
            }

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")

Enumerator Unknown

Enumerator KeyNotWorking

Enumerator NewLicenseNeeded

Enumerator StandardEdition

Enumerator ProfessionalEdition

Enumerator PremiumEdition

Enumerator TooManyInstances

Enumerator NotAuthorized

Enumerator KeyNotFound

Enumerator KeyExpired

Enumerator Timeout

Enumerator InstanceConflict

Enumerator OpticsViewer

Enumerator OpticStudioHPCEdition

Enumerator EnterpriseEdition

Enumerator StudentEdition

Enumeration type UpdateStatus

Definition:

enum UpdateStatus {
  CheckFailed = -2,
  NotSupported = -1,
  NotChecked = 0,
  UpToDate = 1,
  AvailableEligible = 2,
  AvailableIneligible = 3
}

Enumerator CheckFailed

Enumerator NotSupported

Enumerator NotChecked

Enumerator UpToDate

Enumerator AvailableEligible

Enumerator AvailableIneligible

Enumeration type ZOSAPI_Mode

Definition:

enum ZOSAPI_Mode {
  Server,
  Operand,
  Plugin,
  UserAnalysis,
  UserAnalysisSettings
}

Enumerator Server

The connection is running in server or headless mode.

Enumerator Operand

User operand mode.

Enumerator Plugin

Extension mode.

Enumerator UserAnalysis

User analysis mode &ndash perform the calculation.

Enumerator UserAnalysisSettings

User analysis mode &ndash display/configure the analysis settings.

Enumeration type LensUpdateMode

Definition:

enum LensUpdateMode {
  None = 0,
  EditorsOnly = 1,
  AllWindows = 2
}

Enumerator None

Enumerator EditorsOnly

Enumerator AllWindows

Enumeration type SessionModes

Definition:

enum SessionModes {
  FromPreferences = 0,
  SessionOn = 1,
  SessionOff = 2
}

Enumerator FromPreferences

Enumerator SessionOn

Enumerator SessionOff

Enumeration type STARUpdateMode

Definition:

enum STARUpdateMode {
  Normal,
  Suspended
}

Enumerator Normal

Enumerator Suspended

Functions

Function OpticalSystemStatusChangedHandler

delegate void ZOSAPI.OpticalSystemStatusChangedHandler(int systemId, string newStatus)

Parameters:

  • int systemId
  • string newStatus

Return type: delegate void

Connect with Ansys