    

 ## On this page

  

 

 # Example 19 - C# 

 Last update: 16.07.2025 

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

using System;

using [ZOSAPI](namespace_z_o_s_a_p_i.xhtml);

using [ZOSAPI.SystemData](namespace_z_o_s_a_p_i_1_1_system_data.xhtml);

using [ZOSAPI.Editors](namespace_z_o_s_a_p_i_1_1_editors.xhtml);

using [ZOSAPI.Editors.LDE](namespace_z_o_s_a_p_i_1_1_editors_1_1_l_d_e.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 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);

 

 // This code build a chain of prisms based on the KB article:

 // http://zemax.com/os/resources/learn/knowledgebase/how-to-work-in-global-coordinates-in-a-sequential

 TheSystem.[New](interface_z_o_s_a_p_i_1_1_i_optical_system.xhtml#a77b5517fb230d393cf7db82d8fee8a86)(false);

 

 // ISystemData represents the System Explorer in GUI.

 // We access options in System Explorer through ISystemData in ZOS-API

 [ISystemData](interface_z_o_s_a_p_i_1_1_system_data_1_1_i_system_data.xhtml) TheSystemData = TheSystem.[SystemData](interface_z_o_s_a_p_i_1_1_i_optical_system.xhtml#a4c4e9771e9ea51766885fdd6fb6627f5);

 TheSystemData.Aperture.ApertureValue = 10;

 TheSystemData.Aperture.AFocalImageSpace = true;

 TheSystemData.[Wavelengths](interface_z_o_s_a_p_i_1_1_system_data_1_1_i_system_data.xhtml#adc3ab867ef04c79e760a3726b9509fa7).[GetWavelength](interface_z_o_s_a_p_i_1_1_system_data_1_1_i_wavelengths.xhtml#a31ddb977e30e298c8f8281b0694af0c9)(1).[Wavelength](interface_z_o_s_a_p_i_1_1_system_data_1_1_i_wavelength.xhtml#a2f68612c372cdf2bf87a169090304a94) = 0.55;

 

 // Get interface of Lens Data Editor and add 3 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);

 TheLDE.[InsertNewSurfaceAt](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_lens_data_editor.xhtml#a921fc6dbf53c68b79b520193e1907dc9)(2);

 TheLDE.[InsertNewSurfaceAt](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_lens_data_editor.xhtml#a921fc6dbf53c68b79b520193e1907dc9)(2);

 TheLDE.[InsertNewSurfaceAt](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_lens_data_editor.xhtml#a921fc6dbf53c68b79b520193e1907dc9)(2);

 

 // Set thickness and material for each surface.

 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).[Thickness](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_l_d_e_row.xhtml#a06e8f1479eeba5ae70b2f6082bb5ee71) = 30;

 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).[Thickness](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_l_d_e_row.xhtml#a06e8f1479eeba5ae70b2f6082bb5ee71) = 20;

 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)(4).[Thickness](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_l_d_e_row.xhtml#a06e8f1479eeba5ae70b2f6082bb5ee71) = 30;

 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).[Material](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_l_d_e_row.xhtml#a2088af685ee6bc4416425f75ff2e4275) = "N-BK7";

 

 // GetSurfaceAt(surface number shown in LDE) will return an interface ILDERow

 // Through property TiltDecenterData of each interface ILDERow, we can modify data in Surface Properties &gt; Tilt/Decenter section

 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).[TiltDecenterData](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_l_d_e_row.xhtml#a94ba13bcfab0df5fd691a503d373504c).[BeforeSurfaceOrder](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_l_d_e_tilt_decenter_data.xhtml#a4ea131c0c61fcb637370c64c95617b1d) = [TiltDecenterOrderType](namespace_z_o_s_a_p_i_1_1_editors_1_1_l_d_e.xhtml#a7de46ca15ac43175ee1671ef0ad03dd0).Decenter_Tilt;

 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).[TiltDecenterData](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_l_d_e_row.xhtml#a94ba13bcfab0df5fd691a503d373504c).[BeforeSurfaceTiltX](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_l_d_e_tilt_decenter_data.xhtml#aecd58413b4158963121a05c9e45d46d3) = 15;

 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).[TiltDecenterData](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_l_d_e_row.xhtml#a94ba13bcfab0df5fd691a503d373504c).[AfterSurfaceTiltX](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_l_d_e_tilt_decenter_data.xhtml#a714972568d80954de02bd08834658485) = -15;

 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).[TiltDecenterData](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_l_d_e_row.xhtml#a94ba13bcfab0df5fd691a503d373504c).[BeforeSurfaceTiltX](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_l_d_e_tilt_decenter_data.xhtml#aecd58413b4158963121a05c9e45d46d3) = -15;

 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).[TiltDecenterData](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_l_d_e_row.xhtml#a94ba13bcfab0df5fd691a503d373504c).[AfterSurfaceTiltX](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_l_d_e_tilt_decenter_data.xhtml#a714972568d80954de02bd08834658485) = 15;

 

 // To specify an aperture to a surface, we need to first create an ISurfaceApertureType and then assign it.

 [ISurfaceApertureType](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_surface_aperture_type.xhtml) Rect_Aper = 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).[ApertureData](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_l_d_e_row.xhtml#ac0a3ea5103e2dda26276cfcb90c38432).[CreateApertureTypeSettings](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_l_d_e_aperture_data.xhtml#a4dbb443475e2249c33d73b10c50c8ece)([SurfaceApertureTypes](namespace_z_o_s_a_p_i_1_1_editors_1_1_l_d_e.xhtml#a15ca451182bc7f44b720da80d58d9830).RectangularAperture);

 Rect_Aper._S_RectangularAperture.XHalfWidth = 10;

 Rect_Aper._S_RectangularAperture.YHalfWidth = 10;

 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).[ApertureData](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_l_d_e_row.xhtml#ac0a3ea5103e2dda26276cfcb90c38432).[ChangeApertureTypeSettings](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_l_d_e_aperture_data.xhtml#a14089fd69c14646e13d066f718d084d1)(Rect_Aper);

 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).[ApertureData](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_l_d_e_row.xhtml#ac0a3ea5103e2dda26276cfcb90c38432).[PickupFrom](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_l_d_e_aperture_data.xhtml#a95f7da62e392cf29eb8e5cbfae106adf) = 2;

 

 // To change surface type, we need to first get an ISurfaceTypesettings and then assign it.

 [ISurfaceTypeSettings](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_surface_type_settings.xhtml) SurfaceType_CB = 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)(4).[GetSurfaceTypeSettings](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_l_d_e_row.xhtml#a664a633a9e227c6c637aaa86ca72f159)([SurfaceType](namespace_z_o_s_a_p_i_1_1_editors_1_1_l_d_e.xhtml#a1481c47c02108d8faf7204b17fcc25ad).CoordinateBreak);

 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)(4).[ChangeType](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_l_d_e_row.xhtml#a6ec5d7cedce07c2f4695061cd46cc6b8)(SurfaceType_CB);

 

 // Set Chief Ray solves to surface 4, which is Coordinate Break

 // To set a solve to a cell in editor, we need to first create a ISolveData and then assign it.

 [ISolveData](interface_z_o_s_a_p_i_1_1_editors_1_1_i_solve_data.xhtml) Solve_ChiefNormal = 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)(4).[GetSurfaceCell](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_l_d_e_row.xhtml#a67a923405ddad0c066132feaf486e581)([SurfaceColumn](namespace_z_o_s_a_p_i_1_1_editors_1_1_l_d_e.xhtml#ad5f58db223456ac24920f46ac6d62412).Par1).[CreateSolveType](interface_z_o_s_a_p_i_1_1_editors_1_1_i_editor_cell.xhtml#aab9b45b0e5c224d1fb31bce66888d20d)([SolveType](namespace_z_o_s_a_p_i_1_1_editors.xhtml#a0e4579c2bd01e606f5ba9e7f7ad1b0ec).PickupChiefRay);

 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)(4).[GetSurfaceCell](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_l_d_e_row.xhtml#a67a923405ddad0c066132feaf486e581)([SurfaceColumn](namespace_z_o_s_a_p_i_1_1_editors_1_1_l_d_e.xhtml#ad5f58db223456ac24920f46ac6d62412).Par1).[SetSolveData](interface_z_o_s_a_p_i_1_1_editors_1_1_i_editor_cell.xhtml#a5c0cbba814207920589ee69ffcfc0d36)(Solve_ChiefNormal);

 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)(4).[GetSurfaceCell](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_l_d_e_row.xhtml#a67a923405ddad0c066132feaf486e581)([SurfaceColumn](namespace_z_o_s_a_p_i_1_1_editors_1_1_l_d_e.xhtml#ad5f58db223456ac24920f46ac6d62412).Par2).[SetSolveData](interface_z_o_s_a_p_i_1_1_editors_1_1_i_editor_cell.xhtml#a5c0cbba814207920589ee69ffcfc0d36)(Solve_ChiefNormal);

 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)(4).[GetSurfaceCell](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_l_d_e_row.xhtml#a67a923405ddad0c066132feaf486e581)([SurfaceColumn](namespace_z_o_s_a_p_i_1_1_editors_1_1_l_d_e.xhtml#ad5f58db223456ac24920f46ac6d62412).Par3).[SetSolveData](interface_z_o_s_a_p_i_1_1_editors_1_1_i_editor_cell.xhtml#a5c0cbba814207920589ee69ffcfc0d36)(Solve_ChiefNormal);

 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)(4).[GetSurfaceCell](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_l_d_e_row.xhtml#a67a923405ddad0c066132feaf486e581)([SurfaceColumn](namespace_z_o_s_a_p_i_1_1_editors_1_1_l_d_e.xhtml#ad5f58db223456ac24920f46ac6d62412).Par4).[SetSolveData](interface_z_o_s_a_p_i_1_1_editors_1_1_i_editor_cell.xhtml#a5c0cbba814207920589ee69ffcfc0d36)(Solve_ChiefNormal);

 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)(4).[GetSurfaceCell](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_l_d_e_row.xhtml#a67a923405ddad0c066132feaf486e581)([SurfaceColumn](namespace_z_o_s_a_p_i_1_1_editors_1_1_l_d_e.xhtml#ad5f58db223456ac24920f46ac6d62412).Par5).[SetSolveData](interface_z_o_s_a_p_i_1_1_editors_1_1_i_editor_cell.xhtml#a5c0cbba814207920589ee69ffcfc0d36)(Solve_ChiefNormal);

 

 // Copy 3 surfaces starting from surface number 2 in LDE and paste to surface number 5, 

 // which will become surface number 8 after pasting.

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

 {

 TheLDE.[CopySurfaces](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_lens_data_editor.xhtml#a06c92b97bb74eeb5cc78d47323213199)(2, 3, 5);

 }

 // Save file

 TheSystem.[SaveAs](interface_z_o_s_a_p_i_1_1_i_optical_system.xhtml#a32d2f472d9a6d3277f3cda76afb6d85d)(TheApplication.[SamplesDir](interface_z_o_s_a_p_i_1_1_i_z_o_s_a_p_i___application.xhtml#ae8fc2a9409927955cc362f9262b052bb) + "\\\\API\\\\CS\\\\e19\_Sample\_Prism\_Chain.zos");

 

 

 

 // Run tool Convert Local To Global Coordinates to convert surface #2 to surface #35 to be globally referenced to surface #1

 TheLDE.[RunTool\_ConvertLocalToGlobalCoordinates](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_lens_data_editor.xhtml#a12a8490ebb2b82b8458bf6cd4a80cf72)(2, 35, 1);

 TheSystem.[SaveAs](interface_z_o_s_a_p_i_1_1_i_optical_system.xhtml#a32d2f472d9a6d3277f3cda76afb6d85d)(TheApplication.[SamplesDir](interface_z_o_s_a_p_i_1_1_i_z_o_s_a_p_i___application.xhtml#ae8fc2a9409927955cc362f9262b052bb) + "\\\\API\\\\CS\\\\e19\_Sample\_Prism\_Chain\_GlobalCoordinate.zos");

 

 // Run tool Conver Global To Local Coordinates to convert surface #1 to surface #57 back to local coordinate.

 TheLDE.[RunTool\_ConvertGlobalToLocalCoordinates](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_lens_data_editor.xhtml#a6edb7490aecc68244e0c0d8c56eac70a)(1, 57, 0);

 TheSystem.[SaveAs](interface_z_o_s_a_p_i_1_1_i_optical_system.xhtml#a32d2f472d9a6d3277f3cda76afb6d85d)(TheApplication.[SamplesDir](interface_z_o_s_a_p_i_1_1_i_z_o_s_a_p_i___application.xhtml#ae8fc2a9409927955cc362f9262b052bb) + "\\\\API\\\\CS\\\\e19\_Sample\_Prism\_Chain\_BackTo\_LocalCoordinate.zos");

 

 Console.Write("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.Editors.IEditorCell.SetSolveData](interface_z_o_s_a_p_i_1_1_editors_1_1_i_editor_cell.xhtml#a5c0cbba814207920589ee69ffcfc0d36)

SolveStatus SetSolveData(ISolveData Data)

Updates the system with the new solve type settings (see also CreateSolveType and GetSolveData).



[ZOSAPI.Editors.IEditorCell.CreateSolveType](interface_z_o_s_a_p_i_1_1_editors_1_1_i_editor_cell.xhtml#aab9b45b0e5c224d1fb31bce66888d20d)

ISolveData CreateSolveType(SolveType type)

Creates the solve type settings for the specified solve type. Note that SetSolveData must be used to ...



[ZOSAPI.Editors.ISolveData](interface_z_o_s_a_p_i_1_1_editors_1_1_i_solve_data.xhtml)

Base interface for all solve types. This interface can be accesed via the IEditorCell interface....

**Definition:** InterfacesEditors.cs:563



[ZOSAPI.Editors.LDE.ILDEApertureData.ChangeApertureTypeSettings](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_l_d_e_aperture_data.xhtml#a14089fd69c14646e13d066f718d084d1)

bool ChangeApertureTypeSettings(ISurfaceApertureType settings)

Updates the surface aperture with the specified settings. Use CurrentTypeSettings or CreateApertureTy...



[ZOSAPI.Editors.LDE.ILDEApertureData.CreateApertureTypeSettings](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_l_d_e_aperture_data.xhtml#a4dbb443475e2249c33d73b10c50c8ece)

ISurfaceApertureType CreateApertureTypeSettings(SurfaceApertureTypes type)

Creates the a settings interface for the specified aperture type. Note that changing these settings w...



[ZOSAPI.Editors.LDE.ILDEApertureData.PickupFrom](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_l_d_e_aperture_data.xhtml#a95f7da62e392cf29eb8e5cbfae106adf)

int PickupFrom

Gets or sets the surface to pickup settings from.

**Definition:** InterfacesLDE.cs:4884



[ZOSAPI.Editors.LDE.ILDERow.Thickness](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_l_d_e_row.xhtml#a06e8f1479eeba5ae70b2f6082bb5ee71)

double Thickness

Gets or sets the surface thickness.

**Definition:** InterfacesLDE.cs:1009



[ZOSAPI.Editors.LDE.ILDERow.Material](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_l_d_e_row.xhtml#a2088af685ee6bc4416425f75ff2e4275)

string Material

**Definition:** InterfacesLDE.cs:1023



[ZOSAPI.Editors.LDE.ILDERow.GetSurfaceTypeSettings](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_l_d_e_row.xhtml#a664a633a9e227c6c637aaa86ca72f159)

ISurfaceTypeSettings GetSurfaceTypeSettings(SurfaceType type)

Create the settings for the specified type. Use this method to specify any extra data required to cha...



[ZOSAPI.Editors.LDE.ILDERow.GetSurfaceCell](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_l_d_e_row.xhtml#a67a923405ddad0c066132feaf486e581)

IEditorCell GetSurfaceCell(SurfaceColumn Col)

Gets the specified surface cell data.



[ZOSAPI.Editors.LDE.ILDERow.ChangeType](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_l_d_e_row.xhtml#a6ec5d7cedce07c2f4695061cd46cc6b8)

bool ChangeType(ISurfaceTypeSettings settings)

Changes the current surface to the specified type. Use GetSurfaceTypeSettings to get the relevant set...



[ZOSAPI.Editors.LDE.ILDERow.TiltDecenterData](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_l_d_e_row.xhtml#a94ba13bcfab0df5fd691a503d373504c)

ILDETiltDecenterData TiltDecenterData

Gets the surface Tile/Decenter data.

**Definition:** InterfacesLDE.cs:933



[ZOSAPI.Editors.LDE.ILDERow.ApertureData](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_l_d_e_row.xhtml#ac0a3ea5103e2dda26276cfcb90c38432)

ILDEApertureData ApertureData

Gets the surface Aperture data.

**Definition:** InterfacesLDE.cs:919



[ZOSAPI.Editors.LDE.ILDETiltDecenterData.BeforeSurfaceOrder](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_l_d_e_tilt_decenter_data.xhtml#a4ea131c0c61fcb637370c64c95617b1d)

TiltDecenterOrderType BeforeSurfaceOrder

**Definition:** InterfacesLDE.cs:5397



[ZOSAPI.Editors.LDE.ILDETiltDecenterData.AfterSurfaceTiltX](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_l_d_e_tilt_decenter_data.xhtml#a714972568d80954de02bd08834658485)

double AfterSurfaceTiltX

**Definition:** InterfacesLDE.cs:5417



[ZOSAPI.Editors.LDE.ILDETiltDecenterData.BeforeSurfaceTiltX](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_l_d_e_tilt_decenter_data.xhtml#aecd58413b4158963121a05c9e45d46d3)

double BeforeSurfaceTiltX

**Definition:** InterfacesLDE.cs:5400



[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.CopySurfaces](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_lens_data_editor.xhtml#a06c92b97bb74eeb5cc78d47323213199)

int CopySurfaces(int fromSurfaceNumber, int NumberOfSurfaces, int toSurfaceNumber)

Copy and paste the specified number of surfaces from one location to another. Note that it is okay ...



[ZOSAPI.Editors.LDE.ILensDataEditor.RunTool\_ConvertLocalToGlobalCoordinates](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_lens_data_editor.xhtml#a12a8490ebb2b82b8458bf6cd4a80cf72)

CoordinateConversionResult RunTool_ConvertLocalToGlobalCoordinates(int FirstSurface, int LastSurface, int referenceSurface)

Converts Local to Global coordinates.



[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.LDE.ILensDataEditor.RunTool\_ConvertGlobalToLocalCoordinates](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_lens_data_editor.xhtml#a6edb7490aecc68244e0c0d8c56eac70a)

CoordinateConversionResult RunTool_ConvertGlobalToLocalCoordinates(int FirstSurface, int LastSurface, ConversionOrder order)

Converts Global to Local coordinates.



[ZOSAPI.Editors.LDE.ILensDataEditor.InsertNewSurfaceAt](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_lens_data_editor.xhtml#a921fc6dbf53c68b79b520193e1907dc9)

ILDERow InsertNewSurfaceAt(int SurfaceNumber)

Inserts a new surface at the specified position.



[ZOSAPI.Editors.LDE.ISurfaceApertureType](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_surface_aperture_type.xhtml)

Base interface for settings specific to a SurfaceApertureTypes. This interface can be retrieved from ...

**Definition:** InterfacesLDE.cs:4976



[ZOSAPI.Editors.LDE.ISurfaceTypeSettings](interface_z_o_s_a_p_i_1_1_editors_1_1_l_d_e_1_1_i_surface_type_settings.xhtml)

This interface is used for selecting any files required by a surface, and for changing surface types....

**Definition:** InterfacesLDE.cs:746



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

void New(bool saveIfNeeded)

Clears all data in the current system and resets it to a default state.



[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.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.SystemData.ISystemData](interface_z_o_s_a_p_i_1_1_system_data_1_1_i_system_data.xhtml)

Interfaces and methods for changing all System Explorer data. This interface can be accessed via the ...

**Definition:** InterfacesSE.cs:275



[ZOSAPI.SystemData.ISystemData.Wavelengths](interface_z_o_s_a_p_i_1_1_system_data_1_1_i_system_data.xhtml#adc3ab867ef04c79e760a3726b9509fa7)

IWavelengths Wavelengths

**Definition:** InterfacesSE.cs:277



[ZOSAPI.SystemData.IWavelength.Wavelength](interface_z_o_s_a_p_i_1_1_system_data_1_1_i_wavelength.xhtml#a2f68612c372cdf2bf87a169090304a94)

double Wavelength

**Definition:** InterfacesSE.cs:768



[ZOSAPI.SystemData.IWavelengths.GetWavelength](interface_z_o_s_a_p_i_1_1_system_data_1_1_i_wavelengths.xhtml#a31ddb977e30e298c8f8281b0694af0c9)

IWavelength GetWavelength(int position)

Gets the specified wavelength."/&gt;.



[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.LDE.SurfaceType](namespace_z_o_s_a_p_i_1_1_editors_1_1_l_d_e.xhtml#a1481c47c02108d8faf7204b17fcc25ad)

SurfaceType

All available surface types.

**Definition:** InterfacesLDE.cs:27



[ZOSAPI.Editors.LDE.SurfaceApertureTypes](namespace_z_o_s_a_p_i_1_1_editors_1_1_l_d_e.xhtml#a15ca451182bc7f44b720da80d58d9830)

SurfaceApertureTypes

**Definition:** InterfacesLDE.cs:4844



[ZOSAPI.Editors.LDE.TiltDecenterOrderType](namespace_z_o_s_a_p_i_1_1_editors_1_1_l_d_e.xhtml#a7de46ca15ac43175ee1671ef0ad03dd0)

TiltDecenterOrderType

**Definition:** InterfacesLDE.cs:5353



[ZOSAPI.Editors.LDE.SurfaceColumn](namespace_z_o_s_a_p_i_1_1_editors_1_1_l_d_e.xhtml#ad5f58db223456ac24920f46ac6d62412)

SurfaceColumn

**Definition:** InterfacesLDE.cs:136



[ZOSAPI.Editors](namespace_z_o_s_a_p_i_1_1_editors.xhtml)

**Definition:** InterfacesEditors.cs:12



[ZOSAPI.Editors.SolveType](namespace_z_o_s_a_p_i_1_1_editors.xhtml#a0e4579c2bd01e606f5ba9e7f7ad1b0ec)

SolveType

All solve types available. Note that only a portion of the types are available for any given IEditorC...

**Definition:** InterfacesEditors.cs:483



[ZOSAPI.SystemData](namespace_z_o_s_a_p_i_1_1_system_data.xhtml)

**Definition:** InterfacesSE.cs:11



[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