    

 ## On this page

  

 

 # Example 23 - C# 

 Last update: 17.07.2025 

# <a class="anchor" id="ex23_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);

 

 int max_rays = 150;

 // determines the max field number and max field value

 double max_field = 0;

 for (int i = 1; i &lt;= TheSystem.[SystemData](interface_z_o_s_a_p_i_1_1_i_optical_system.xhtml#a4c4e9771e9ea51766885fdd6fb6627f5).Fields.NumberOfFields; 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;

 }

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

 

 System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch();

 stopWatch.Start();

 

 // 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;

 [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, [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, px = 0;

 double[] py_ary = new double[max_rays + 1];

 for (int i = 0; i &lt;= max_rays; i++)

 {

 py_ary[i] = i / (double)max_rays * 2 - 1;

 }

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

 

 // image surface number and primary wavelength

 int pwav = 0;

 for (int a = 1; a &lt;= TheSystem.[SystemData](interface_z_o_s_a_p_i_1_1_i_optical_system.xhtml#a4c4e9771e9ea51766885fdd6fb6627f5).Wavelengths.NumberOfWavelengths; a++)

 {

 if (TheSystem.[SystemData](interface_z_o_s_a_p_i_1_1_i_optical_system.xhtml#a4c4e9771e9ea51766885fdd6fb6627f5).Wavelengths.GetWavelength(a).IsPrimary)

 pwav = a;

 }

 

 // creates array of Y coordinate chief ray values

 double[] chief_ary = new double[max_num_field];

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

 {

 double hy = TheSystem.[SystemData](interface_z_o_s_a_p_i_1_1_i_optical_system.xhtml#a4c4e9771e9ea51766885fdd6fb6627f5).Fields.GetField(field).Y / max_field;

 // gets single value without using MFE(see ZPL OPEV)

 chief_ary[field - 1] = TheSystem.[MFE](interface_z_o_s_a_p_i_1_1_i_optical_system.xhtml#ac427705057fa09ec839220a094f3033f).GetOperandValue([ZOSAPI](namespace_z_o_s_a_p_i.xhtml).[Editors](namespace_z_o_s_a_p_i_1_1_editors.xhtml).[MFE](namespace_z_o_s_a_p_i_1_1_editors_1_1_m_f_e.xhtml).MeritOperandType.REAY, nsur, pwav, 0, hy, 0, 0, 0, 0);

 }

 

 // initialize x / y image plane arrays

 double[,,] y_ary = new double[max_num_field, max_wave, max_rays + 1];

 

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

 sbReport.AppendLine("Manual Code");

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

 

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

 {

 double hy = TheSystem.[SystemData](interface_z_o_s_a_p_i_1_1_i_optical_system.xhtml#a4c4e9771e9ea51766885fdd6fb6627f5).Fields.GetField(field).Y / max_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)();

 for (int i = 0; i &lt;= max_rays; i++)

 {

 double py = py_ary[i];

 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)(wave, hx, hy, 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))

 {

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

 sbReport.AppendLine((field).ToString() + "\\t" + (wave).ToString() + "\\t" + py_ary[rayNumber - 1].ToString() + "\\t" + ((double_Y - chief_ary[field - 1]) * 1000).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("");

 }

 }

 

 double manual = (double)stopWatch.ElapsedMilliseconds / 1000;

 stopWatch.Reset();

 stopWatch.Start();

 

 // runs a ray fan analysis and extracts 

 [ZOSAPI.Analysis.IA\_](interface_z_o_s_a_p_i_1_1_analysis_1_1_i_a__.xhtml) ray = 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.RayFan);

 [ZOSAPI.Analysis.Settings.Fans.IAS\_Fan](interface_z_o_s_a_p_i_1_1_analysis_1_1_settings_1_1_fans_1_1_i_a_s___fan.xhtml) ray_settings = ([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).[Fans](namespace_z_o_s_a_p_i_1_1_analysis_1_1_settings_1_1_fans.xhtml).[IAS\_Fan](interface_z_o_s_a_p_i_1_1_analysis_1_1_settings_1_1_fans_1_1_i_a_s___fan.xhtml))ray.[GetSettings](interface_z_o_s_a_p_i_1_1_analysis_1_1_i_a__.xhtml#af82c93423d06452642e5cb31203cc109)();

 ray_settings.NumberOfRays = max_rays / 2;

 ray_settings.[Field](interface_z_o_s_a_p_i_1_1_analysis_1_1_settings_1_1_fans_1_1_i_a_s___fan.xhtml#abe35038fd68b4e52a6c5442679d46254).[UseAllFields](interface_z_o_s_a_p_i_1_1_analysis_1_1_settings_1_1_i_a_s___field.xhtml#a324cd487899583ae73400414de2de58f)();

 ray_settings.[Wavelength](interface_z_o_s_a_p_i_1_1_analysis_1_1_settings_1_1_fans_1_1_i_a_s___fan.xhtml#a1970c1bcfd0088cd316bbab86deb6529).[UseAllWavelengths](interface_z_o_s_a_p_i_1_1_analysis_1_1_settings_1_1_i_a_s___wavelength.xhtml#a705563143354dc20713a8f169911bc83)();

 

 ray.[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) ray_results = ray.[GetResults](interface_z_o_s_a_p_i_1_1_analysis_1_1_i_a__.xhtml#a4c6f286eaffe67e97984cf1f91cc5cef)();

 

 double native = (double)stopWatch.ElapsedMilliseconds / 1000;

 

 sbReport.AppendLine("Native Code");

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

 {

 // Read the results

 double[] x = new double[ray_results.[DataSeries](interface_z_o_s_a_p_i_1_1_analysis_1_1_data_1_1_i_a_r__.xhtml#a9412e7e789091546b4e0e568cf8839da)[field * 2 - 2].[XData](interface_z_o_s_a_p_i_1_1_analysis_1_1_data_1_1_i_a_r___data_series.xhtml#a83aaff0e2b0dd0794b9c6f22e5c89f3d).Length];

 double[,] y = new double[ray_results.[DataSeries](interface_z_o_s_a_p_i_1_1_analysis_1_1_data_1_1_i_a_r__.xhtml#a9412e7e789091546b4e0e568cf8839da)[field * 2 - 2].[YData](interface_z_o_s_a_p_i_1_1_analysis_1_1_data_1_1_i_a_r___data_series.xhtml#a7724e43c32625fdb176d9130f20ce5ee).Rows, ray_results.[DataSeries](interface_z_o_s_a_p_i_1_1_analysis_1_1_data_1_1_i_a_r__.xhtml#a9412e7e789091546b4e0e568cf8839da)[field * 2 - 2].[YData](interface_z_o_s_a_p_i_1_1_analysis_1_1_data_1_1_i_a_r___data_series.xhtml#a7724e43c32625fdb176d9130f20ce5ee).Cols];

 

 x = ray_results.[DataSeries](interface_z_o_s_a_p_i_1_1_analysis_1_1_data_1_1_i_a_r__.xhtml#a9412e7e789091546b4e0e568cf8839da)[field * 2 - 2].[XData](interface_z_o_s_a_p_i_1_1_analysis_1_1_data_1_1_i_a_r___data_series.xhtml#a83aaff0e2b0dd0794b9c6f22e5c89f3d).Data;

 y = ray_results.[DataSeries](interface_z_o_s_a_p_i_1_1_analysis_1_1_data_1_1_i_a_r__.xhtml#a9412e7e789091546b4e0e568cf8839da)[field * 2 - 2].[YData](interface_z_o_s_a_p_i_1_1_analysis_1_1_data_1_1_i_a_r___data_series.xhtml#a7724e43c32625fdb176d9130f20ce5ee).Data;

 for (int row = 0; row &lt; x.Length; row++)

 {

 sbReport.Append(x[row].ToString() + '\\t');

 for (int col = 0; col &lt; ray_results.[DataSeries](interface_z_o_s_a_p_i_1_1_analysis_1_1_data_1_1_i_a_r__.xhtml#a9412e7e789091546b4e0e568cf8839da)[field * 2 - 2].[YData](interface_z_o_s_a_p_i_1_1_analysis_1_1_data_1_1_i_a_r___data_series.xhtml#a7724e43c32625fdb176d9130f20ce5ee).Cols; col++)

 {

 sbReport.Append(y[row, col].ToString() + '\\t');

 }

 sbReport.Append('\\n');

 }

 sbReport.AppendLine("");

 }

 

 // outputs execution time

 Console.WriteLine("Elapsed time is {0:F4} seconds with native code", native);

 Console.WriteLine("Elapsed time is {0:F4} seconds with manual code", manual);

 

 // writes data to file

 string resFile = System.IO.Path.Combine(sampleDir, "API\\\\CS\\\\e23\_ray\_fan\_native\_manual\_comparison.txt");

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

 

 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\_DataSeries.YData](interface_z_o_s_a_p_i_1_1_analysis_1_1_data_1_1_i_a_r___data_series.xhtml#a7724e43c32625fdb176d9130f20ce5ee)

IMatrixData YData

**Definition:** IAR_Base.cs:381



[ZOSAPI.Analysis.Data.IAR\_DataSeries.XData](interface_z_o_s_a_p_i_1_1_analysis_1_1_data_1_1_i_a_r___data_series.xhtml#a83aaff0e2b0dd0794b9c6f22e5c89f3d)

IVectorData XData

**Definition:** IAR_Base.cs:377



[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\_.DataSeries](interface_z_o_s_a_p_i_1_1_analysis_1_1_data_1_1_i_a_r__.xhtml#a9412e7e789091546b4e0e568cf8839da)

IAR_DataSeries[] DataSeries

**Definition:** IAR_Base.cs:71



[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.Fans.IAS\_Fan](interface_z_o_s_a_p_i_1_1_analysis_1_1_settings_1_1_fans_1_1_i_a_s___fan.xhtml)

**Definition:** IAS_Fan.cs:24



[ZOSAPI.Analysis.Settings.Fans.IAS\_Fan.Wavelength](interface_z_o_s_a_p_i_1_1_analysis_1_1_settings_1_1_fans_1_1_i_a_s___fan.xhtml#a1970c1bcfd0088cd316bbab86deb6529)

IAS_Wavelength Wavelength

**Definition:** IAS_Fan.cs:27



[ZOSAPI.Analysis.Settings.Fans.IAS\_Fan.Field](interface_z_o_s_a_p_i_1_1_analysis_1_1_settings_1_1_fans_1_1_i_a_s___fan.xhtml#abe35038fd68b4e52a6c5442679d46254)

IAS_Field Field

**Definition:** IAS_Fan.cs:25



[ZOSAPI.Analysis.Settings.IAS\_Field.UseAllFields](interface_z_o_s_a_p_i_1_1_analysis_1_1_settings_1_1_i_a_s___field.xhtml#a324cd487899583ae73400414de2de58f)

IMessage UseAllFields()



[ZOSAPI.Analysis.Settings.IAS\_Wavelength.UseAllWavelengths](interface_z_o_s_a_p_i_1_1_analysis_1_1_settings_1_1_i_a_s___wavelength.xhtml#a705563143354dc20713a8f169911bc83)

IMessage UseAllWavelengths()



[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.MFE](interface_z_o_s_a_p_i_1_1_i_optical_system.xhtml#ac427705057fa09ec839220a094f3033f)

IMeritFunctionEditor MFE

Gets the merit function editor.

**Definition:** Interfaces.cs:910



[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.Fans](namespace_z_o_s_a_p_i_1_1_analysis_1_1_settings_1_1_fans.xhtml)

**Definition:** IAS_Fan.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.MFE](namespace_z_o_s_a_p_i_1_1_editors_1_1_m_f_e.xhtml)

**Definition:** InterfacesMFE.cs:12



[ZOSAPI.Editors](namespace_z_o_s_a_p_i_1_1_editors.xhtml)

**Definition:** InterfacesEditors.cs:12



[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