    

 ## On this page

  

 

 # Example 22 - C# 

 Last update: 17.07.2025 

# <a class="anchor" id="ex22_s1"></a>C#

using System;

using [ZOSAPI](namespace_z_o_s_a_p_i.xhtml);

 

namespace CSharpStandaloneApplication

{

 class Program

 {

 static void Main(string[] args)

 {

 // Find the installed version of OpticStudio

 bool isInitialized = ZOSAPI_NetHelper.ZOSAPI_Initializer.Initialize();

 // Note -- uncomment the following line to use a custom initialization path

 //bool isInitialized = ZOSAPI\_NetHelper.ZOSAPI\_Initializer.Initialize(@"C:\\Program Files\\OpticStudio\\");

 if (isInitialized)

 {

 LogInfo("Found OpticStudio at: " + ZOSAPI_NetHelper.ZOSAPI_Initializer.GetZemaxDirectory());

 }

 else

 {

 HandleError("Failed to locate OpticStudio!");

 return;

 }

 

 BeginStandaloneApplication();

 }

 

 static void BeginStandaloneApplication()

 {

 // Create the initial connection class

 [ZOSAPI\_Connection](class_z_o_s_a_p_i_1_1_z_o_s_a_p_i___connection.xhtml) TheConnection = new [ZOSAPI\_Connection](class_z_o_s_a_p_i_1_1_z_o_s_a_p_i___connection.xhtml)();

 

 // Attempt to create a Standalone connection

 [IZOSAPI\_Application](interface_z_o_s_a_p_i_1_1_i_z_o_s_a_p_i___application.xhtml) TheApplication = TheConnection.[CreateNewApplication](class_z_o_s_a_p_i_1_1_z_o_s_a_p_i___connection.xhtml#aadc54af7d7415a765592acf23d3a08ef)();

 if (TheApplication == null)

 {

 HandleError("An unknown connection error occurred!");

 return;

 }

 

 // Check the connection status

 if (!TheApplication.[IsValidLicenseForAPI](interface_z_o_s_a_p_i_1_1_i_z_o_s_a_p_i___application.xhtml#a5b8d6c216c668d13d6dcb870698c247f))

 {

 HandleError("Failed to connect to OpticStudio: " + TheApplication.[LicenseStatus](interface_z_o_s_a_p_i_1_1_i_z_o_s_a_p_i___application.xhtml#a95179eb8038b629caa12397723aacb3a));

 return;

 }

 if (TheApplication.[Mode](interface_z_o_s_a_p_i_1_1_i_z_o_s_a_p_i___application.xhtml#a8d2a89bafe9778c14f592276e5a5eb19) != [ZOSAPI\_Mode](namespace_z_o_s_a_p_i.xhtml#a254f5f6cb4ff37c2245b456b9bb79d2a).Server)

 {

 HandleError("User plugin was started in the wrong mode: expected Server, found " + TheApplication.[Mode](interface_z_o_s_a_p_i_1_1_i_z_o_s_a_p_i___application.xhtml#a8d2a89bafe9778c14f592276e5a5eb19).ToString());

 return;

 }

 

 [IOpticalSystem](interface_z_o_s_a_p_i_1_1_i_optical_system.xhtml) TheSystem = TheApplication.[PrimarySystem](interface_z_o_s_a_p_i_1_1_i_z_o_s_a_p_i___application.xhtml#aca8045fe84351622e0ee58814a2a3364);

 

 // creates new directory

 string strPath = System.IO.Path.Combine(TheApplication.[SamplesDir](interface_z_o_s_a_p_i_1_1_i_z_o_s_a_p_i___application.xhtml#ae8fc2a9409927955cc362f9262b052bb), @"API\\CS");

 System.IO.Directory.CreateDirectory(strPath);

 

 // Set up primary optical system

 string sampleDir = TheApplication.[SamplesDir](interface_z_o_s_a_p_i_1_1_i_z_o_s_a_p_i___application.xhtml#ae8fc2a9409927955cc362f9262b052bb);

 string testFile = System.IO.Path.Combine(sampleDir, "Sequential\\\\Objectives\\\\Double Gauss 28 degree field.zos");

 TheSystem.[LoadFile](interface_z_o_s_a_p_i_1_1_i_optical_system.xhtml#a6eb1455ac53555ae6f30032d85b63735)(testFile, false);

 

 // Set up Batch Ray Trace

 [ZOSAPI.Tools.RayTrace.IBatchRayTrace](interface_z_o_s_a_p_i_1_1_tools_1_1_ray_trace_1_1_i_batch_ray_trace.xhtml) raytrace = TheSystem.[Tools](interface_z_o_s_a_p_i_1_1_i_optical_system.xhtml#add3e3631eadf7955b7b341179ff1eff8).OpenBatchRayTrace();

 int nsur = TheSystem.[LDE](interface_z_o_s_a_p_i_1_1_i_optical_system.xhtml#a942995136e3c3cf875cc1fde38d33477).NumberOfSurfaces;

 int max_rays = 30;

 [ZOSAPI.Tools.RayTrace.IRayTraceNormUnpolData](interface_z_o_s_a_p_i_1_1_tools_1_1_ray_trace_1_1_i_ray_trace_norm_unpol_data.xhtml) normUnPolData = raytrace.[CreateNormUnpol](interface_z_o_s_a_p_i_1_1_tools_1_1_ray_trace_1_1_i_batch_ray_trace.xhtml#a9bba4e0c9125e31f778462bbfa30a2cb)((max_rays + 1) * (max_rays + 1), [ZOSAPI](namespace_z_o_s_a_p_i.xhtml).[Tools](namespace_z_o_s_a_p_i_1_1_tools.xhtml).[RayTrace](namespace_z_o_s_a_p_i_1_1_tools_1_1_ray_trace.xhtml).RaysType.Real, nsur);

 

 // Define batch ray trace constants

 double hx = 0.0;

 int max_wave = TheSystem.[SystemData](interface_z_o_s_a_p_i_1_1_i_optical_system.xhtml#a4c4e9771e9ea51766885fdd6fb6627f5).Wavelengths.NumberOfWavelengths;

 int num_fields = TheSystem.[SystemData](interface_z_o_s_a_p_i_1_1_i_optical_system.xhtml#a4c4e9771e9ea51766885fdd6fb6627f5).Fields.NumberOfFields;

 double[] hy_ary = new double[] { 0, 0.707, 1 };

 

 // Initialize x/y image plane arrays

 double[,,] x_ary = new double[num_fields, max_wave, (max_rays + 1) * (max_rays + 1)];

 double[,,] y_ary = new double[num_fields, max_wave, (max_rays + 1) * (max_rays + 1)];

 

 // Determine maximum field in Y only

 double max_field = 0.0;

 for (int i = 1; i &lt;= num_fields; i++)

 {

 if (TheSystem.[SystemData](interface_z_o_s_a_p_i_1_1_i_optical_system.xhtml#a4c4e9771e9ea51766885fdd6fb6627f5).Fields.GetField(i).Y &gt; max_field)

 {

 max_field = TheSystem.[SystemData](interface_z_o_s_a_p_i_1_1_i_optical_system.xhtml#a4c4e9771e9ea51766885fdd6fb6627f5).Fields.GetField(i).Y;

 }

 }

 

 [Random](namespace_z_o_s_a_p_i_1_1_editors_1_1_n_c_e.xhtml#a664c238076b0d36a2391819c17b0c1d1a64663f4646781c9c0110838b905daa23) rand = new [Random](namespace_z_o_s_a_p_i_1_1_editors_1_1_n_c_e.xhtml#a664c238076b0d36a2391819c17b0c1d1a64663f4646781c9c0110838b905daa23)();

 

 System.Text.StringBuilder sbReport = new System.Text.StringBuilder();

 sbReport.AppendLine("Field \\t Wave \\t x \\t y");

 

 for (int field = 1; field &lt;= num_fields; field++)

 {

 for (int wave = 1; wave &lt;= max_wave; wave++)

 {

 // Adding Rays to Batch, varying normalised object height hy

 normUnPolData.[ClearData](interface_z_o_s_a_p_i_1_1_tools_1_1_ray_trace_1_1_i_ray_trace_norm_unpol_data.xhtml#a5763ea79ca85f812d79697337184df81)();

 int waveNumber = wave;

 for (int i = 1; i &lt;= ((max_rays + 1) * (max_rays + 1)); i++)

 {

 double px, py;

 px = rand.NextDouble() * 2 - 1;

 py = rand.NextDouble() * 2 - 1;

 while ((Math.Pow(px, 2) + Math.Pow(py, 2)) &gt; 1)

 {

 py = rand.NextDouble() * 2 - 1;

 }

 normUnPolData.[AddRay](interface_z_o_s_a_p_i_1_1_tools_1_1_ray_trace_1_1_i_ray_trace_norm_unpol_data.xhtml#a06260536d9e2cbad0326c2e376bc1e0c)(waveNumber, hx, hy_ary[field - 1], px, py, [ZOSAPI](namespace_z_o_s_a_p_i.xhtml).[Tools](namespace_z_o_s_a_p_i_1_1_tools.xhtml).[RayTrace](namespace_z_o_s_a_p_i_1_1_tools_1_1_ray_trace.xhtml).OPDMode.None);

 }

 

 // Run Batch Ray Trace

 raytrace.[RunAndWaitForCompletion](interface_z_o_s_a_p_i_1_1_tools_1_1_i_system_tool.xhtml#a26d8cae18772fd31c1d18525a3b8d9ac)();

 

 // Read batch raytrace and save results

 normUnPolData.[StartReadingResults](interface_z_o_s_a_p_i_1_1_tools_1_1_ray_trace_1_1_i_ray_trace_norm_unpol_data.xhtml#a114bc11931f340726de6e1dd4c7f8aae)();

 int rayNumber, ErrorCode, vignetteCode;

 double double_X, double_Y, double_Z, double_L, double_M, double_N, double_L2, double_M2, double_N2, OPD, Intensity;

 bool success;

 

 success = normUnPolData.[ReadNextResult](interface_z_o_s_a_p_i_1_1_tools_1_1_ray_trace_1_1_i_ray_trace_norm_unpol_data.xhtml#add6aeef85c65ae41701924e22675c9b2)(out rayNumber, out ErrorCode, out vignetteCode, out double_X, out double_Y, out double_Z, out double_L, out double_M, out double_N, out double_L2, out double_M2, out double_N2, out OPD, out Intensity);

 while (success)

 {

 if ((ErrorCode == 0) &amp;&amp; (vignetteCode == 0))

 {

 x_ary[field - 1, wave - 1, rayNumber - 1] = double_X;

 y_ary[field - 1, wave - 1, rayNumber - 1] = double_Y;

 sbReport.AppendLine((field).ToString() + "\\t" + (wave).ToString() + "\\t" + double_X.ToString() + "\\t" + double_Y.ToString());

 }

 success = normUnPolData.[ReadNextResult](interface_z_o_s_a_p_i_1_1_tools_1_1_ray_trace_1_1_i_ray_trace_norm_unpol_data.xhtml#add6aeef85c65ae41701924e22675c9b2)(out rayNumber, out ErrorCode, out vignetteCode, out double_X, out double_Y, out double_Z, out double_L, out double_M, out double_N, out double_L2, out double_M2, out double_N2, out OPD, out Intensity);

 }

 sbReport.AppendLine("");

 }

 }

 

 string resFile = System.IO.Path.Combine(sampleDir, "API\\\\CS\\\\e22\_seq\_spot\_diagram.txt");

 System.IO.File.WriteAllText(resFile, sbReport.ToString());

 

 // Spot Diagram Analysis Results

 [ZOSAPI.Analysis.IA\_](interface_z_o_s_a_p_i_1_1_analysis_1_1_i_a__.xhtml) spot = TheSystem.[Analyses](interface_z_o_s_a_p_i_1_1_i_optical_system.xhtml#a830cf50c046528c752605eea3cf5e899).New_Analysis([ZOSAPI](namespace_z_o_s_a_p_i.xhtml).[Analysis](namespace_z_o_s_a_p_i_1_1_analysis.xhtml).AnalysisIDM.StandardSpot);

 [ZOSAPI.Analysis.Settings.Spot.IAS\_Spot](interface_z_o_s_a_p_i_1_1_analysis_1_1_settings_1_1_spot_1_1_i_a_s___spot.xhtml) spot_setting = ([ZOSAPI](namespace_z_o_s_a_p_i.xhtml).[Analysis](namespace_z_o_s_a_p_i_1_1_analysis.xhtml).[Settings](namespace_z_o_s_a_p_i_1_1_analysis_1_1_settings.xhtml).[Spot](namespace_z_o_s_a_p_i_1_1_analysis_1_1_settings_1_1_spot.xhtml).[IAS\_Spot](interface_z_o_s_a_p_i_1_1_analysis_1_1_settings_1_1_spot_1_1_i_a_s___spot.xhtml))spot.[GetSettings](interface_z_o_s_a_p_i_1_1_analysis_1_1_i_a__.xhtml#af82c93423d06452642e5cb31203cc109)();

 spot_setting.[Field](interface_z_o_s_a_p_i_1_1_analysis_1_1_settings_1_1_spot_1_1_i_a_s___spot.xhtml#a48f3e03fca527bd2ef081f3e8fe5b185).[SetFieldNumber](interface_z_o_s_a_p_i_1_1_analysis_1_1_settings_1_1_i_a_s___field.xhtml#a7b9004baddc986212ba158bbdbad3d76)(0);

 spot_setting.[Wavelength](interface_z_o_s_a_p_i_1_1_analysis_1_1_settings_1_1_spot_1_1_i_a_s___spot.xhtml#af17353a5d59cf503f0f2d14109121979).[SetWavelengthNumber](interface_z_o_s_a_p_i_1_1_analysis_1_1_settings_1_1_i_a_s___wavelength.xhtml#ad1d058bf101a8055b9280b0ead9ae5c5)(0);

 spot_setting.ReferTo = [ZOSAPI](namespace_z_o_s_a_p_i.xhtml).[Analysis](namespace_z_o_s_a_p_i_1_1_analysis.xhtml).[Settings](namespace_z_o_s_a_p_i_1_1_analysis_1_1_settings.xhtml).[Spot](namespace_z_o_s_a_p_i_1_1_analysis_1_1_settings_1_1_spot.xhtml).Reference.Centroid;

 

 // Extract RMS &amp; Geo spot size for field points

 spot.[ApplyAndWaitForCompletion](interface_z_o_s_a_p_i_1_1_analysis_1_1_i_a__.xhtml#aff285af72f196b9c4915c531ff9873a4)();

 [ZOSAPI.Analysis.Data.IAR\_](interface_z_o_s_a_p_i_1_1_analysis_1_1_data_1_1_i_a_r__.xhtml) spot_results = spot.[GetResults](interface_z_o_s_a_p_i_1_1_analysis_1_1_i_a__.xhtml#a4c6f286eaffe67e97984cf1f91cc5cef)();

 Console.WriteLine("RMS radius: {0:F3} {1:F3} {2:F3}", spot_results.[SpotData](interface_z_o_s_a_p_i_1_1_analysis_1_1_data_1_1_i_a_r__.xhtml#a2e52480086bc2854c1bc9d7c7888123f).[GetRMSSpotSizeFor](interface_z_o_s_a_p_i_1_1_analysis_1_1_data_1_1_i_a_r___spot_data_result_matrix.xhtml#a17359801dacfb1ac80570e2eca07a95a)(1, 1), spot_results.[SpotData](interface_z_o_s_a_p_i_1_1_analysis_1_1_data_1_1_i_a_r__.xhtml#a2e52480086bc2854c1bc9d7c7888123f).[GetRMSSpotSizeFor](interface_z_o_s_a_p_i_1_1_analysis_1_1_data_1_1_i_a_r___spot_data_result_matrix.xhtml#a17359801dacfb1ac80570e2eca07a95a)(2, 1), spot_results.[SpotData](interface_z_o_s_a_p_i_1_1_analysis_1_1_data_1_1_i_a_r__.xhtml#a2e52480086bc2854c1bc9d7c7888123f).[GetRMSSpotSizeFor](interface_z_o_s_a_p_i_1_1_analysis_1_1_data_1_1_i_a_r___spot_data_result_matrix.xhtml#a17359801dacfb1ac80570e2eca07a95a)(3, 1));

 Console.WriteLine("GEO radius: {0:F3} {1:F3} {2:F3}", spot_results.[SpotData](interface_z_o_s_a_p_i_1_1_analysis_1_1_data_1_1_i_a_r__.xhtml#a2e52480086bc2854c1bc9d7c7888123f).[GetGeoSpotSizeFor](interface_z_o_s_a_p_i_1_1_analysis_1_1_data_1_1_i_a_r___spot_data_result_matrix.xhtml#a8f205893bdd60f4ad12c126bbfd80a22)(1, 1), spot_results.[SpotData](interface_z_o_s_a_p_i_1_1_analysis_1_1_data_1_1_i_a_r__.xhtml#a2e52480086bc2854c1bc9d7c7888123f).[GetGeoSpotSizeFor](interface_z_o_s_a_p_i_1_1_analysis_1_1_data_1_1_i_a_r___spot_data_result_matrix.xhtml#a8f205893bdd60f4ad12c126bbfd80a22)(2, 1), spot_results.[SpotData](interface_z_o_s_a_p_i_1_1_analysis_1_1_data_1_1_i_a_r__.xhtml#a2e52480086bc2854c1bc9d7c7888123f).[GetGeoSpotSizeFor](interface_z_o_s_a_p_i_1_1_analysis_1_1_data_1_1_i_a_r___spot_data_result_matrix.xhtml#a8f205893bdd60f4ad12c126bbfd80a22)(3, 1));

 Console.WriteLine("Press any key to continue...");

 Console.ReadKey();

 

 // Clean up

 FinishStandaloneApplication(TheApplication);

 }

 

 static void FinishStandaloneApplication([IZOSAPI\_Application](interface_z_o_s_a_p_i_1_1_i_z_o_s_a_p_i___application.xhtml) TheApplication)

 {

 // Note - TheApplication will close automatically when this application exits, so this isn't strictly necessary in most cases

 if (TheApplication != null)

 {

 TheApplication.[CloseApplication](interface_z_o_s_a_p_i_1_1_i_z_o_s_a_p_i___application.xhtml#ab662a3cc1b97d8632a324b1137fa943b)();

 }

 }

 

 static void LogInfo(string message)

 {

 // TODO - add custom logging

 Console.WriteLine(message);

 }

 

 static void HandleError(string errorMessage)

 {

 // TODO - add custom error handling

 throw new Exception(errorMessage);

 }

 

 }

}

[ZOSAPI.ZOSAPI\_Connection](class_z_o_s_a_p_i_1_1_z_o_s_a_p_i___connection.xhtml)

**Definition:** ZemaxService.cs:198



[ZOSAPI.ZOSAPI\_Connection.CreateNewApplication](class_z_o_s_a_p_i_1_1_z_o_s_a_p_i___connection.xhtml#aadc54af7d7415a765592acf23d3a08ef)

IZOSAPI_Application CreateNewApplication()

Attempts to launch a new instance of Optic Studio in 'headless' mode. Note that although the Optic St...

**Definition:** ZemaxService.cs:864



[ZOSAPI.Analysis.Data.IAR\_SpotDataResultMatrix.GetRMSSpotSizeFor](interface_z_o_s_a_p_i_1_1_analysis_1_1_data_1_1_i_a_r___spot_data_result_matrix.xhtml#a17359801dacfb1ac80570e2eca07a95a)

double GetRMSSpotSizeFor(int fieldN, int waveN)



[ZOSAPI.Analysis.Data.IAR\_SpotDataResultMatrix.GetGeoSpotSizeFor](interface_z_o_s_a_p_i_1_1_analysis_1_1_data_1_1_i_a_r___spot_data_result_matrix.xhtml#a8f205893bdd60f4ad12c126bbfd80a22)

double GetGeoSpotSizeFor(int fieldN, int waveN)



[ZOSAPI.Analysis.Data.IAR\_](interface_z_o_s_a_p_i_1_1_analysis_1_1_data_1_1_i_a_r__.xhtml)

Properties and methods for retrieving analysis window data. This interface can be accessed via the IA...

**Definition:** IAR_Base.cs:21



[ZOSAPI.Analysis.Data.IAR\_.SpotData](interface_z_o_s_a_p_i_1_1_analysis_1_1_data_1_1_i_a_r__.xhtml#a2e52480086bc2854c1bc9d7c7888123f)

IAR_SpotDataResultMatrix SpotData

**Definition:** IAR_Base.cs:104



[ZOSAPI.Analysis.IA\_](interface_z_o_s_a_p_i_1_1_analysis_1_1_i_a__.xhtml)

Base interface for all analysis windows. This interface can be accessed via the I_Analyses interface.

**Definition:** IA_Base.cs:29



[ZOSAPI.Analysis.IA\_.GetResults](interface_z_o_s_a_p_i_1_1_analysis_1_1_i_a__.xhtml#a4c6f286eaffe67e97984cf1f91cc5cef)

IAR_ GetResults()

Gets the result data (if available) for the current analysis.



[ZOSAPI.Analysis.IA\_.GetSettings](interface_z_o_s_a_p_i_1_1_analysis_1_1_i_a__.xhtml#af82c93423d06452642e5cb31203cc109)

IAS_ GetSettings()

Gets the settings for the current analysis.



[ZOSAPI.Analysis.IA\_.ApplyAndWaitForCompletion](interface_z_o_s_a_p_i_1_1_analysis_1_1_i_a__.xhtml#aff285af72f196b9c4915c531ff9873a4)

IMessage ApplyAndWaitForCompletion()

Re-runs the analysis with the current settings and waits for it to finish calculating.



[ZOSAPI.Analysis.Settings.IAS\_Field.SetFieldNumber](interface_z_o_s_a_p_i_1_1_analysis_1_1_settings_1_1_i_a_s___field.xhtml#a7b9004baddc986212ba158bbdbad3d76)

IMessage SetFieldNumber(int N)



[ZOSAPI.Analysis.Settings.IAS\_Wavelength.SetWavelengthNumber](interface_z_o_s_a_p_i_1_1_analysis_1_1_settings_1_1_i_a_s___wavelength.xhtml#ad1d058bf101a8055b9280b0ead9ae5c5)

IMessage SetWavelengthNumber(int N)



[ZOSAPI.Analysis.Settings.Spot.IAS\_Spot](interface_z_o_s_a_p_i_1_1_analysis_1_1_settings_1_1_spot_1_1_i_a_s___spot.xhtml)

**Definition:** IAS_Spot.cs:50



[ZOSAPI.Analysis.Settings.Spot.IAS\_Spot.Field](interface_z_o_s_a_p_i_1_1_analysis_1_1_settings_1_1_spot_1_1_i_a_s___spot.xhtml#a48f3e03fca527bd2ef081f3e8fe5b185)

IAS_Field Field

**Definition:** IAS_Spot.cs:51



[ZOSAPI.Analysis.Settings.Spot.IAS\_Spot.Wavelength](interface_z_o_s_a_p_i_1_1_analysis_1_1_settings_1_1_spot_1_1_i_a_s___spot.xhtml#af17353a5d59cf503f0f2d14109121979)

IAS_Wavelength Wavelength

**Definition:** IAS_Spot.cs:53



[ZOSAPI.IOpticalSystem](interface_z_o_s_a_p_i_1_1_i_optical_system.xhtml)

Represent a complete optical system. A IOpticalSystem corresponds to a single .ZMX file....

**Definition:** Interfaces.cs:687



[ZOSAPI.IOpticalSystem.SystemData](interface_z_o_s_a_p_i_1_1_i_optical_system.xhtml#a4c4e9771e9ea51766885fdd6fb6627f5)

ISystemData SystemData

Data for configuring everything in the System Explorer.

**Definition:** Interfaces.cs:845



[ZOSAPI.IOpticalSystem.LoadFile](interface_z_o_s_a_p_i_1_1_i_optical_system.xhtml#a6eb1455ac53555ae6f30032d85b63735)

bool LoadFile(string LensFile, bool saveIfNeeded)

Replaces the current system with data from the specified file.



[ZOSAPI.IOpticalSystem.Analyses](interface_z_o_s_a_p_i_1_1_i_optical_system.xhtml#a830cf50c046528c752605eea3cf5e899)

I_Analyses Analyses

Gets the analyses for the current system.

**Definition:** Interfaces.cs:925



[ZOSAPI.IOpticalSystem.LDE](interface_z_o_s_a_p_i_1_1_i_optical_system.xhtml#a942995136e3c3cf875cc1fde38d33477)

ILensDataEditor LDE

Gets the lens data editor.

**Definition:** Interfaces.cs:865



[ZOSAPI.IOpticalSystem.Tools](interface_z_o_s_a_p_i_1_1_i_optical_system.xhtml#add3e3631eadf7955b7b341179ff1eff8)

IOpticalSystemTools Tools

Gets an interface used to run various tools on the optical system.

**Definition:** Interfaces.cs:932



[ZOSAPI.IZOSAPI\_Application](interface_z_o_s_a_p_i_1_1_i_z_o_s_a_p_i___application.xhtml)

This interface contains all information about the current ZOS-API connection, as well as methods for ...

**Definition:** Interfaces.cs:261



[ZOSAPI.IZOSAPI\_Application.IsValidLicenseForAPI](interface_z_o_s_a_p_i_1_1_i_z_o_s_a_p_i___application.xhtml#a5b8d6c216c668d13d6dcb870698c247f)

bool IsValidLicenseForAPI

Gets a value indicating whether this the API is currently useable.

**Definition:** Interfaces.cs:287



[ZOSAPI.IZOSAPI\_Application.Mode](interface_z_o_s_a_p_i_1_1_i_z_o_s_a_p_i___application.xhtml#a8d2a89bafe9778c14f592276e5a5eb19)

ZOSAPI_Mode Mode

Gets the current connetion mode. Use this to check if Optic Studio is expecting a user operand / anal...

**Definition:** Interfaces.cs:306



[ZOSAPI.IZOSAPI\_Application.LicenseStatus](interface_z_o_s_a_p_i_1_1_i_z_o_s_a_p_i___application.xhtml#a95179eb8038b629caa12397723aacb3a)

LicenseStatusType LicenseStatus

Gets the license status. Note that this displays the license edition if successful,...

**Definition:** Interfaces.cs:280



[ZOSAPI.IZOSAPI\_Application.CloseApplication](interface_z_o_s_a_p_i_1_1_i_z_o_s_a_p_i___application.xhtml#ab662a3cc1b97d8632a324b1137fa943b)

void CloseApplication()

Shut down the Optic Studio process.



[ZOSAPI.IZOSAPI\_Application.PrimarySystem](interface_z_o_s_a_p_i_1_1_i_z_o_s_a_p_i___application.xhtml#aca8045fe84351622e0ee58814a2a3364)

IOpticalSystem PrimarySystem

Gets the primary system. When Mode is ZOSAPI_Mode.Server, this will initially be an empty sequential ...

**Definition:** Interfaces.cs:328



[ZOSAPI.IZOSAPI\_Application.SamplesDir](interface_z_o_s_a_p_i_1_1_i_z_o_s_a_p_i___application.xhtml#ae8fc2a9409927955cc362f9262b052bb)

string SamplesDir

Gets the full path for the current user's samples directory (in the My Documents\Zemax\Samples\ folde...

**Definition:** Interfaces.cs:505



[ZOSAPI.Tools.ISystemTool.RunAndWaitForCompletion](interface_z_o_s_a_p_i_1_1_tools_1_1_i_system_tool.xhtml#a26d8cae18772fd31c1d18525a3b8d9ac)

bool RunAndWaitForCompletion()

Sames as calling Run followed by WaitForCompletion.



[ZOSAPI.Tools.RayTrace.IBatchRayTrace](interface_z_o_s_a_p_i_1_1_tools_1_1_ray_trace_1_1_i_batch_ray_trace.xhtml)

Interfaces and methods for running a ray trace on multiple rays at a time. This interface can be acce...

**Definition:** RayTrace.cs:239



[ZOSAPI.Tools.RayTrace.IBatchRayTrace.CreateNormUnpol](interface_z_o_s_a_p_i_1_1_tools_1_1_ray_trace_1_1_i_batch_ray_trace.xhtml#a9bba4e0c9125e31f778462bbfa30a2cb)

IRayTraceNormUnpolData CreateNormUnpol(int MaxRays, RaysType rayType, int toSurface)

Performs a batch unpolarized ray trace, using normalized pupil coordinates. See the OpticStudio help ...



[ZOSAPI.Tools.RayTrace.IRayTraceNormUnpolData](interface_z_o_s_a_p_i_1_1_tools_1_1_ray_trace_1_1_i_ray_trace_norm_unpol_data.xhtml)

**Definition:** RayTrace.cs:624



[ZOSAPI.Tools.RayTrace.IRayTraceNormUnpolData.AddRay](interface_z_o_s_a_p_i_1_1_tools_1_1_ray_trace_1_1_i_ray_trace_norm_unpol_data.xhtml#a06260536d9e2cbad0326c2e376bc1e0c)

bool AddRay(int waveNumber, double Hx, double Hy, double Px, double Py, OPDMode calcOPD)

Add a ray to be traced.



[ZOSAPI.Tools.RayTrace.IRayTraceNormUnpolData.StartReadingResults](interface_z_o_s_a_p_i_1_1_tools_1_1_ray_trace_1_1_i_ray_trace_norm_unpol_data.xhtml#a114bc11931f340726de6e1dd4c7f8aae)

bool StartReadingResults()



[ZOSAPI.Tools.RayTrace.IRayTraceNormUnpolData.ClearData](interface_z_o_s_a_p_i_1_1_tools_1_1_ray_trace_1_1_i_ray_trace_norm_unpol_data.xhtml#a5763ea79ca85f812d79697337184df81)

void ClearData()



[ZOSAPI.Tools.RayTrace.IRayTraceNormUnpolData.ReadNextResult](interface_z_o_s_a_p_i_1_1_tools_1_1_ray_trace_1_1_i_ray_trace_norm_unpol_data.xhtml#add6aeef85c65ae41701924e22675c9b2)

bool ReadNextResult(out int rayNumber, out int ErrorCode, out int vignetteCode, out double X, out double Y, out double Z, out double L, out double M, out double N, out double l2, out double m2, out double n2, out double opd, out double intensity)



[ZOSAPI.Analysis.Settings.Spot](namespace_z_o_s_a_p_i_1_1_analysis_1_1_settings_1_1_spot.xhtml)

**Definition:** IAS_Spot.cs:5



[ZOSAPI.Analysis.Settings](namespace_z_o_s_a_p_i_1_1_analysis_1_1_settings.xhtml)

**Definition:** IAS_FieldCurvatureAndDistortion.cs:5



[ZOSAPI.Analysis](namespace_z_o_s_a_p_i_1_1_analysis.xhtml)

**Definition:** IAS_FieldCurvatureAndDistortion.cs:5



[ZOSAPI.Editors.NCE.SourceSamplingMethod.Random](namespace_z_o_s_a_p_i_1_1_editors_1_1_n_c_e.xhtml#a664c238076b0d36a2391819c17b0c1d1a64663f4646781c9c0110838b905daa23)

@ Random



[ZOSAPI.Tools.RayTrace](namespace_z_o_s_a_p_i_1_1_tools_1_1_ray_trace.xhtml)

**Definition:** RayTrace.cs:12



[ZOSAPI.Tools](namespace_z_o_s_a_p_i_1_1_tools.xhtml)

**Definition:** FileSource.cs:4



[ZOSAPI](namespace_z_o_s_a_p_i.xhtml)

The ZOSAPI namespace contains classes for initially connecting to zemax. See also ZOSAPI_Connection,...

**Definition:** IAS_FieldCurvatureAndDistortion.cs:5



[ZOSAPI.ZOSAPI\_Mode](namespace_z_o_s_a_p_i.xhtml#a254f5f6cb4ff37c2245b456b9bb79d2a)

ZOSAPI_Mode

**Definition:** Interfaces.cs:77