    

 ## On this page

  

 

 # Example 03 - C# 

 Last update: 17.07.2025 

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

using System;

using [ZOSAPI](namespace_z_o_s_a_p_i.xhtml);

using [ZOSAPI.Editors.LDE](namespace_z_o_s_a_p_i_1_1_editors_1_1_l_d_e.xhtml);

using [ZOSAPI.Editors.MFE](namespace_z_o_s_a_p_i_1_1_editors_1_1_m_f_e.xhtml);

using [ZOSAPI.Tools.Optimization](namespace_z_o_s_a_p_i_1_1_tools_1_1_optimization.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);

 

 // Add your custom code here...

 

 // creates a new API 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

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

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

 

 // Open file &amp; save a copy

 string testFile = sampleDir + "\\\\API\\\\CS\\\\e01\_new\_file\_and\_quickfocus.zos";

 if (!System.IO.File.Exists(testFile))

 {

 Console.WriteLine("You need to run Example 01 before running this example");

 Console.ReadKey();

 return;

 }

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

 string testFile2 = sampleDir + "\\\\API\\\\CS\\\\e03\_open\_file\_and\_optimise.zos";

 TheSystem.[SaveAs](interface_z_o_s_a_p_i_1_1_i_optical_system.xhtml#a32d2f472d9a6d3277f3cda76afb6d85d)(testFile2);

 

 // Get Surfaces

 [ILensDataEditor](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_lens_data_editor.xhtml) TheLDE = TheSystem.[LDE](interface_z_o_s_a_p_i_1_1_i_optical_system.xhtml#a942995136e3c3cf875cc1fde38d33477);

 [ILDERow](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_l_d_e_row.xhtml) Surface_1 = TheLDE.[GetSurfaceAt](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_lens_data_editor.xhtml#a25b725fa7de9dd2713ed949ac2199b05)(1);

 [ILDERow](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_l_d_e_row.xhtml) Surface_2 = TheLDE.[GetSurfaceAt](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_lens_data_editor.xhtml#a25b725fa7de9dd2713ed949ac2199b05)(2);

 [ILDERow](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_l_d_e_row.xhtml) Surface_3 = TheLDE.[GetSurfaceAt](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_lens_data_editor.xhtml#a25b725fa7de9dd2713ed949ac2199b05)(3);

 

 // Make thicknesses and radii variable

 Surface_1.[ThicknessCell](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_l_d_e_row.xhtml#a1a76b11528342a51e948b5dc0c55e217).[MakeSolveVariable](interface_z_o_s_a_p_i_1_1_editors_1_1_i_editor_cell.xhtml#a74076350d7578c5d5eabb0a35095f9d1)();

 Surface_2.[ThicknessCell](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_l_d_e_row.xhtml#a1a76b11528342a51e948b5dc0c55e217).[MakeSolveVariable](interface_z_o_s_a_p_i_1_1_editors_1_1_i_editor_cell.xhtml#a74076350d7578c5d5eabb0a35095f9d1)();

 Surface_2.[RadiusCell](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_l_d_e_row.xhtml#a919d15dd13c02d96f80586ab6cb8f1a1).[MakeSolveVariable](interface_z_o_s_a_p_i_1_1_editors_1_1_i_editor_cell.xhtml#a74076350d7578c5d5eabb0a35095f9d1)();

 Surface_3.[ThicknessCell](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_l_d_e_row.xhtml#a1a76b11528342a51e948b5dc0c55e217).[MakeSolveVariable](interface_z_o_s_a_p_i_1_1_editors_1_1_i_editor_cell.xhtml#a74076350d7578c5d5eabb0a35095f9d1)();

 

 // Merit functions

 [IMeritFunctionEditor](interface_z_o_s_a_p_i_1_1_editors_1_1_m_f_e_1_1_i_merit_function_editor.xhtml) TheMFE = TheSystem.[MFE](interface_z_o_s_a_p_i_1_1_i_optical_system.xhtml#ac427705057fa09ec839220a094f3033f);

 [IMFERow](interface_z_o_s_a_p_i_1_1_editors_1_1_m_f_e_1_1_i_m_f_e_row.xhtml) Operand_1 = TheMFE.[GetOperandAt](interface_z_o_s_a_p_i_1_1_editors_1_1_m_f_e_1_1_i_merit_function_editor.xhtml#a3fa99092db285aac2e8aaf23fd5b0ee0)(1);

 Operand_1.[ChangeType](interface_z_o_s_a_p_i_1_1_editors_1_1_m_f_e_1_1_i_m_f_e_row.xhtml#aa3ad3be8f26d5617b7b964d0f999d563)([MeritOperandType](namespace_z_o_s_a_p_i_1_1_editors_1_1_m_f_e.xhtml#aa186922480921b908b329f1655025fe4).ASTI);

 Operand_1.Target = 0.0;

 Operand_1.Weight = 10.0;

 

 [IMFERow](interface_z_o_s_a_p_i_1_1_editors_1_1_m_f_e_1_1_i_m_f_e_row.xhtml) Operand_2 = TheMFE.[InsertNewOperandAt](interface_z_o_s_a_p_i_1_1_editors_1_1_m_f_e_1_1_i_merit_function_editor.xhtml#a2db92c30cf543cf1d59ac444af5e0d65)(2);

 Operand_2.[ChangeType](interface_z_o_s_a_p_i_1_1_editors_1_1_m_f_e_1_1_i_m_f_e_row.xhtml#aa3ad3be8f26d5617b7b964d0f999d563)([MeritOperandType](namespace_z_o_s_a_p_i_1_1_editors_1_1_m_f_e.xhtml#aa186922480921b908b329f1655025fe4).COMA);

 Operand_2.Target = 0.0;

 Operand_2.Weight = 1.0;

 // Air min/max

 [IMFERow](interface_z_o_s_a_p_i_1_1_editors_1_1_m_f_e_1_1_i_m_f_e_row.xhtml) Operand_3 = TheMFE.[AddOperand](interface_z_o_s_a_p_i_1_1_editors_1_1_m_f_e_1_1_i_merit_function_editor.xhtml#a04ea0ce475459f7fa7b9f0122378108f)();

 Operand_3.[ChangeType](interface_z_o_s_a_p_i_1_1_editors_1_1_m_f_e_1_1_i_m_f_e_row.xhtml#aa3ad3be8f26d5617b7b964d0f999d563)([MeritOperandType](namespace_z_o_s_a_p_i_1_1_editors_1_1_m_f_e.xhtml#aa186922480921b908b329f1655025fe4).MNCA);

 Operand_3.Target = 0.5;

 Operand_3.Weight = 1.0;

 Operand_3.[GetCellAt](interface_z_o_s_a_p_i_1_1_editors_1_1_i_editor_row.xhtml#a6be57f761b7a17d997dc13c11eda45f9)(2).[IntegerValue](interface_z_o_s_a_p_i_1_1_editors_1_1_i_editor_cell.xhtml#ae449d1e2d9af965fc6cec60f2a9334ce) = 1;

 Operand_3.[GetCellAt](interface_z_o_s_a_p_i_1_1_editors_1_1_i_editor_row.xhtml#a6be57f761b7a17d997dc13c11eda45f9)(3).[IntegerValue](interface_z_o_s_a_p_i_1_1_editors_1_1_i_editor_cell.xhtml#ae449d1e2d9af965fc6cec60f2a9334ce) = 3;

 [IMFERow](interface_z_o_s_a_p_i_1_1_editors_1_1_m_f_e_1_1_i_m_f_e_row.xhtml) Operand_4 = TheMFE.[AddOperand](interface_z_o_s_a_p_i_1_1_editors_1_1_m_f_e_1_1_i_merit_function_editor.xhtml#a04ea0ce475459f7fa7b9f0122378108f)();

 Operand_4.[ChangeType](interface_z_o_s_a_p_i_1_1_editors_1_1_m_f_e_1_1_i_m_f_e_row.xhtml#aa3ad3be8f26d5617b7b964d0f999d563)([MeritOperandType](namespace_z_o_s_a_p_i_1_1_editors_1_1_m_f_e.xhtml#aa186922480921b908b329f1655025fe4).MXCA);

 Operand_4.Target = 1000;

 Operand_4.Weight = 1.0;

 Operand_4.[GetCellAt](interface_z_o_s_a_p_i_1_1_editors_1_1_i_editor_row.xhtml#a6be57f761b7a17d997dc13c11eda45f9)(2).[IntegerValue](interface_z_o_s_a_p_i_1_1_editors_1_1_i_editor_cell.xhtml#ae449d1e2d9af965fc6cec60f2a9334ce) = 1;

 Operand_4.[GetCellAt](interface_z_o_s_a_p_i_1_1_editors_1_1_i_editor_row.xhtml#a6be57f761b7a17d997dc13c11eda45f9)(3).[IntegerValue](interface_z_o_s_a_p_i_1_1_editors_1_1_i_editor_cell.xhtml#ae449d1e2d9af965fc6cec60f2a9334ce) = 3;

 [IMFERow](interface_z_o_s_a_p_i_1_1_editors_1_1_m_f_e_1_1_i_m_f_e_row.xhtml) Operand_5 = TheMFE.[AddOperand](interface_z_o_s_a_p_i_1_1_editors_1_1_m_f_e_1_1_i_merit_function_editor.xhtml#a04ea0ce475459f7fa7b9f0122378108f)();

 Operand_5.[ChangeType](interface_z_o_s_a_p_i_1_1_editors_1_1_m_f_e_1_1_i_m_f_e_row.xhtml#aa3ad3be8f26d5617b7b964d0f999d563)([MeritOperandType](namespace_z_o_s_a_p_i_1_1_editors_1_1_m_f_e.xhtml#aa186922480921b908b329f1655025fe4).MNEA);

 Operand_5.Target = 0.5;

 Operand_5.Weight = 1.0;

 Operand_5.[GetCellAt](interface_z_o_s_a_p_i_1_1_editors_1_1_i_editor_row.xhtml#a6be57f761b7a17d997dc13c11eda45f9)(2).[IntegerValue](interface_z_o_s_a_p_i_1_1_editors_1_1_i_editor_cell.xhtml#ae449d1e2d9af965fc6cec60f2a9334ce) = 1;

 Operand_5.[GetCellAt](interface_z_o_s_a_p_i_1_1_editors_1_1_i_editor_row.xhtml#a6be57f761b7a17d997dc13c11eda45f9)(3).[IntegerValue](interface_z_o_s_a_p_i_1_1_editors_1_1_i_editor_cell.xhtml#ae449d1e2d9af965fc6cec60f2a9334ce) = 3;

 // Material min/max

 [IMFERow](interface_z_o_s_a_p_i_1_1_editors_1_1_m_f_e_1_1_i_m_f_e_row.xhtml) Operand_6 = TheMFE.[AddOperand](interface_z_o_s_a_p_i_1_1_editors_1_1_m_f_e_1_1_i_merit_function_editor.xhtml#a04ea0ce475459f7fa7b9f0122378108f)();

 Operand_6.[ChangeType](interface_z_o_s_a_p_i_1_1_editors_1_1_m_f_e_1_1_i_m_f_e_row.xhtml#aa3ad3be8f26d5617b7b964d0f999d563)([MeritOperandType](namespace_z_o_s_a_p_i_1_1_editors_1_1_m_f_e.xhtml#aa186922480921b908b329f1655025fe4).MNCG);

 Operand_6.Target = 3.0;

 Operand_6.Weight = 1.0;

 Operand_6.[GetCellAt](interface_z_o_s_a_p_i_1_1_editors_1_1_i_editor_row.xhtml#a6be57f761b7a17d997dc13c11eda45f9)(2).[IntegerValue](interface_z_o_s_a_p_i_1_1_editors_1_1_i_editor_cell.xhtml#ae449d1e2d9af965fc6cec60f2a9334ce) = 1;

 Operand_6.[GetCellAt](interface_z_o_s_a_p_i_1_1_editors_1_1_i_editor_row.xhtml#a6be57f761b7a17d997dc13c11eda45f9)(3).[IntegerValue](interface_z_o_s_a_p_i_1_1_editors_1_1_i_editor_cell.xhtml#ae449d1e2d9af965fc6cec60f2a9334ce) = 3;

 [IMFERow](interface_z_o_s_a_p_i_1_1_editors_1_1_m_f_e_1_1_i_m_f_e_row.xhtml) Operand_7 = TheMFE.[AddOperand](interface_z_o_s_a_p_i_1_1_editors_1_1_m_f_e_1_1_i_merit_function_editor.xhtml#a04ea0ce475459f7fa7b9f0122378108f)();

 Operand_7.[ChangeType](interface_z_o_s_a_p_i_1_1_editors_1_1_m_f_e_1_1_i_m_f_e_row.xhtml#aa3ad3be8f26d5617b7b964d0f999d563)([MeritOperandType](namespace_z_o_s_a_p_i_1_1_editors_1_1_m_f_e.xhtml#aa186922480921b908b329f1655025fe4).MXCG);

 Operand_7.Target = 15.0;

 Operand_7.Weight = 1.0;

 Operand_7.[GetCellAt](interface_z_o_s_a_p_i_1_1_editors_1_1_i_editor_row.xhtml#a6be57f761b7a17d997dc13c11eda45f9)(2).[IntegerValue](interface_z_o_s_a_p_i_1_1_editors_1_1_i_editor_cell.xhtml#ae449d1e2d9af965fc6cec60f2a9334ce) = 1;

 Operand_7.[GetCellAt](interface_z_o_s_a_p_i_1_1_editors_1_1_i_editor_row.xhtml#a6be57f761b7a17d997dc13c11eda45f9)(3).[IntegerValue](interface_z_o_s_a_p_i_1_1_editors_1_1_i_editor_cell.xhtml#ae449d1e2d9af965fc6cec60f2a9334ce) = 3;

 [IMFERow](interface_z_o_s_a_p_i_1_1_editors_1_1_m_f_e_1_1_i_m_f_e_row.xhtml) Operand_8 = TheMFE.[AddOperand](interface_z_o_s_a_p_i_1_1_editors_1_1_m_f_e_1_1_i_merit_function_editor.xhtml#a04ea0ce475459f7fa7b9f0122378108f)();

 Operand_8.[ChangeType](interface_z_o_s_a_p_i_1_1_editors_1_1_m_f_e_1_1_i_m_f_e_row.xhtml#aa3ad3be8f26d5617b7b964d0f999d563)([MeritOperandType](namespace_z_o_s_a_p_i_1_1_editors_1_1_m_f_e.xhtml#aa186922480921b908b329f1655025fe4).MNEG);

 Operand_8.Target = 3.0;

 Operand_8.Weight = 1.0;

 Operand_8.[GetCellAt](interface_z_o_s_a_p_i_1_1_editors_1_1_i_editor_row.xhtml#a6be57f761b7a17d997dc13c11eda45f9)(2).[IntegerValue](interface_z_o_s_a_p_i_1_1_editors_1_1_i_editor_cell.xhtml#ae449d1e2d9af965fc6cec60f2a9334ce) = 1;

 Operand_8.[GetCellAt](interface_z_o_s_a_p_i_1_1_editors_1_1_i_editor_row.xhtml#a6be57f761b7a17d997dc13c11eda45f9)(3).[IntegerValue](interface_z_o_s_a_p_i_1_1_editors_1_1_i_editor_cell.xhtml#ae449d1e2d9af965fc6cec60f2a9334ce) = 3;

 

 // Local optimisation till completion

 [ILocalOptimization](interface_z_o_s_a_p_i_1_1_tools_1_1_optimization_1_1_i_local_optimization.xhtml) LocalOpt = TheSystem.[Tools](interface_z_o_s_a_p_i_1_1_i_optical_system.xhtml#add3e3631eadf7955b7b341179ff1eff8).OpenLocalOptimization();

 LocalOpt.Algorithm = [OptimizationAlgorithm](namespace_z_o_s_a_p_i_1_1_tools_1_1_optimization.xhtml#abdfc45ae891097832d05ef1853e36917).DampedLeastSquares;

 LocalOpt.Cycles = [OptimizationCycles](namespace_z_o_s_a_p_i_1_1_tools_1_1_optimization.xhtml#a67304d58fe61f0276971736aa671f68b).Automatic;

 LocalOpt.NumberOfCores = 8;

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

 LocalOpt.[Close](interface_z_o_s_a_p_i_1_1_tools_1_1_i_system_tool.xhtml#a5bfa126385b9d0c5619b1aff9a354d31)();

 

 // Hammer for 10 seconds

 Console.WriteLine("Running Hammer for 10 seconds");

 [IHammerOptimization](interface_z_o_s_a_p_i_1_1_tools_1_1_optimization_1_1_i_hammer_optimization.xhtml) HammerOpt = TheSystem.[Tools](interface_z_o_s_a_p_i_1_1_i_optical_system.xhtml#add3e3631eadf7955b7b341179ff1eff8).OpenHammerOptimization();

 HammerOpt.[RunAndWaitWithTimeout](interface_z_o_s_a_p_i_1_1_tools_1_1_i_system_tool.xhtml#ae61b47060b4f3ed933b13d794725984e)(10); // 10s of Hammer

 HammerOpt.[Cancel](interface_z_o_s_a_p_i_1_1_tools_1_1_i_system_tool.xhtml#a7802878e38f79b8d8c42a22c83a174b6)();

 HammerOpt.[WaitForCompletion](interface_z_o_s_a_p_i_1_1_tools_1_1_i_system_tool.xhtml#a9076ae50de72dddc49039fd1378ef3db)();

 HammerOpt.[Close](interface_z_o_s_a_p_i_1_1_tools_1_1_i_system_tool.xhtml#a5bfa126385b9d0c5619b1aff9a354d31)();

 

 // Save and close

 TheSystem.[Save](interface_z_o_s_a_p_i_1_1_i_optical_system.xhtml#a8e1c511cdf7f6048f1287532edd3aadd)();

 

 Console.WriteLine("Press ENTER 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.Editors.IEditorCell.MakeSolveVariable](interface_z_o_s_a_p_i_1_1_editors_1_1_i_editor_cell.xhtml#a74076350d7578c5d5eabb0a35095f9d1)

bool MakeSolveVariable()

Sets the solve type to SolveType.Variable.



[ZOSAPI.Editors.IEditorCell.IntegerValue](interface_z_o_s_a_p_i_1_1_editors_1_1_i_editor_cell.xhtml#ae449d1e2d9af965fc6cec60f2a9334ce)

int IntegerValue

Gets or sets the integer value of this cell. Note that if DataType is not CellDataType....

**Definition:** InterfacesEditors.cs:319



[ZOSAPI.Editors.IEditorRow.GetCellAt](interface_z_o_s_a_p_i_1_1_editors_1_1_i_editor_row.xhtml#a6be57f761b7a17d997dc13c11eda45f9)

IEditorCell GetCellAt(int pos)

Gets the cell at the specified index (IEditor.MinColumn to IEditor.MaxColumn).



[ZOSAPI.Editors.LDE.ILDERow](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_l_d_e_row.xhtml)

All data for a Lens Data Editor surface. This interface can be accessed via the ILensDataEditor inter...

**Definition:** InterfacesLDE.cs:791



[ZOSAPI.Editors.LDE.ILDERow.ThicknessCell](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_l_d_e_row.xhtml#a1a76b11528342a51e948b5dc0c55e217)

IEditorCell ThicknessCell

**Definition:** InterfacesLDE.cs:1010



[ZOSAPI.Editors.LDE.ILDERow.RadiusCell](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_l_d_e_row.xhtml#a919d15dd13c02d96f80586ab6cb8f1a1)

IEditorCell RadiusCell

**Definition:** InterfacesLDE.cs:990



[ZOSAPI.Editors.LDE.ILensDataEditor](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_lens_data_editor.xhtml)

This interface defines all properties and methods needed to interact with the Lens Data Editor....

**Definition:** InterfacesLDE.cs:265



[ZOSAPI.Editors.LDE.ILensDataEditor.GetSurfaceAt](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_lens_data_editor.xhtml#a25b725fa7de9dd2713ed949ac2199b05)

ILDERow GetSurfaceAt(int SurfaceNumber)

Gets the data for the specified surface.



[ZOSAPI.Editors.MFE.IMFERow](interface_z_o_s_a_p_i_1_1_editors_1_1_m_f_e_1_1_i_m_f_e_row.xhtml)

All data for a Merit Function Editor operand. This interface can be accessed via the IMeritFunctionEd...

**Definition:** InterfacesMFE.cs:696



[ZOSAPI.Editors.MFE.IMFERow.ChangeType](interface_z_o_s_a_p_i_1_1_editors_1_1_m_f_e_1_1_i_m_f_e_row.xhtml#aa3ad3be8f26d5617b7b964d0f999d563)

bool ChangeType(MeritOperandType type)

Changes to the specified operand type.



[ZOSAPI.Editors.MFE.IMeritFunctionEditor](interface_z_o_s_a_p_i_1_1_editors_1_1_m_f_e_1_1_i_merit_function_editor.xhtml)

This interface defines all properties and methods needed to interact with the MRit Function Editor....

**Definition:** InterfacesMFE.cs:491



[ZOSAPI.Editors.MFE.IMeritFunctionEditor.AddOperand](interface_z_o_s_a_p_i_1_1_editors_1_1_m_f_e_1_1_i_merit_function_editor.xhtml#a04ea0ce475459f7fa7b9f0122378108f)

IMFERow AddOperand()

Adds a new operand as the last operand in the system.



[ZOSAPI.Editors.MFE.IMeritFunctionEditor.InsertNewOperandAt](interface_z_o_s_a_p_i_1_1_editors_1_1_m_f_e_1_1_i_merit_function_editor.xhtml#a2db92c30cf543cf1d59ac444af5e0d65)

IMFERow InsertNewOperandAt(int OperandNumber)

Inserts a new operand at the specified position.



[ZOSAPI.Editors.MFE.IMeritFunctionEditor.GetOperandAt](interface_z_o_s_a_p_i_1_1_editors_1_1_m_f_e_1_1_i_merit_function_editor.xhtml#a3fa99092db285aac2e8aaf23fd5b0ee0)

IMFERow GetOperandAt(int OperandNumber)

Gets the data for the specified operand.



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

void SaveAs(string fileName)

Saves the current system to the specified file. All future calls to Save will use the same file.



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

void Save()

Saves the current system.



[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.ISystemTool.Close](interface_z_o_s_a_p_i_1_1_tools_1_1_i_system_tool.xhtml#a5bfa126385b9d0c5619b1aff9a354d31)

bool Close()

Closes this tool and frees up and associated resources.



[ZOSAPI.Tools.ISystemTool.Cancel](interface_z_o_s_a_p_i_1_1_tools_1_1_i_system_tool.xhtml#a7802878e38f79b8d8c42a22c83a174b6)

bool Cancel()

Cancels the currently running asynchronous tool.



[ZOSAPI.Tools.ISystemTool.WaitForCompletion](interface_z_o_s_a_p_i_1_1_tools_1_1_i_system_tool.xhtml#a9076ae50de72dddc49039fd1378ef3db)

bool WaitForCompletion()

Waits for the asynchronous tool to complete.



[ZOSAPI.Tools.ISystemTool.RunAndWaitWithTimeout](interface_z_o_s_a_p_i_1_1_tools_1_1_i_system_tool.xhtml#ae61b47060b4f3ed933b13d794725984e)

RunStatus RunAndWaitWithTimeout(double timeOutSeconds)

Starts the tool running, and waits for it to complete with the specified timeout value....



[ZOSAPI.Tools.Optimization.IHammerOptimization](interface_z_o_s_a_p_i_1_1_tools_1_1_optimization_1_1_i_hammer_optimization.xhtml)

Interfaces and methods for running a Hammer Optimization. This interface can be accessed via the IOpt...

**Definition:** Optimization.cs:170



[ZOSAPI.Tools.Optimization.ILocalOptimization](interface_z_o_s_a_p_i_1_1_tools_1_1_optimization_1_1_i_local_optimization.xhtml)

Interfaces and methods for running a Local Optimization. This interface can be accessed via the IOpti...

**Definition:** Optimization.cs:50



[ZOSAPI.Editors.LDE](namespace_z_o_s_a_p_i_1_1_editors_1_1_l_d_e.xhtml)

**Definition:** InterfacesLDE.cs:8



[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.MFE.MeritOperandType](namespace_z_o_s_a_p_i_1_1_editors_1_1_m_f_e.xhtml#aa186922480921b908b329f1655025fe4)

MeritOperandType

All supported Merit Function operands.

**Definition:** InterfacesMFE.cs:19



[ZOSAPI.Tools.Optimization](namespace_z_o_s_a_p_i_1_1_tools_1_1_optimization.xhtml)

**Definition:** Optimization.cs:9



[ZOSAPI.Tools.Optimization.OptimizationCycles](namespace_z_o_s_a_p_i_1_1_tools_1_1_optimization.xhtml#a67304d58fe61f0276971736aa671f68b)

OptimizationCycles

**Definition:** Optimization.cs:22



[ZOSAPI.Tools.Optimization.OptimizationAlgorithm](namespace_z_o_s_a_p_i_1_1_tools_1_1_optimization.xhtml#abdfc45ae891097832d05ef1853e36917)

OptimizationAlgorithm

**Definition:** Optimization.cs:14



[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