File Tools.cs
Last update: 13.03.2026Classes
- ZOSAPI::Tools::IHPCSettings
- ZOSAPI::Tools::IOpticalSystemTools
- ZOSAPI::Tools::IAPIUtilities
- ZOSAPI::Tools::ISystemTool
- ZOSAPI::Tools::General::IQuickAdjust
- ZOSAPI::Tools::General::IQuickFocus
- ZOSAPI::Tools::General::IRestoreArchive
- ZOSAPI::Tools::General::IRestoreProject
- ZOSAPI::Tools::General::ICreateArchive
- ZOSAPI::Tools::General::ICreateProject
- ZOSAPI::Tools::General::IExportCAD
- ZOSAPI::Tools::General::ILensCatalogs
- ZOSAPI::Tools::General::ILensCatalogLens
- ZOSAPI::Tools::General::IScale
- ZOSAPI::Tools::General::IComputeRMSSpotSize
- ZOSAPI::Tools::General::IDataDictionary
- ZOSAPI::Tools::General::IDataEntry
- ZOSAPI::Tools::General::IPoint3D
- ZOSAPI::Tools::General::IPointList3D
- ZOSAPI::Tools::General::IPointTools
- ZOSAPI::Tools::General::ICovarianceData
- ZOSAPI::Tools::General::IHullTools
- ZOSAPI::Tools::General::IRayAimingWizard
Namespaces
Source
using System;
using System.Runtime.InteropServices;
using ZOSAPI.Analysis;
using ZOSAPI.Common;
using ZOSAPI.SystemData;
using ZOSAPI.Tools.General;
using ZOSAPI.Tools.Optimization;
using ZOSAPI.Tools.OptimizationTools;
using ZOSAPI.Tools.RayTrace;
using ZOSAPI.Tools.Sequences;
using ZOSAPI.Tools.Tolerancing;
namespace ZOSAPI.Tools
{
#if true
[ComVisible(true)]
[Guid("4F13590C-46B1-45B2-85DD-29F452114868")]
public enum HPCEnvironments
{
OnPremise = 0,
AWSKubernetes,
AzureKubernetes,
}
[ComVisible(true)]
[Guid("9D48486B-6A56-4E70-82E3-C25340373EB1")]
public enum HPCNodeSize
{
Default = 0,
Tiny = 1,
Small = 2,
Medium = 3,
Large = 4,
XLarge = 5,
}
[ComVisible(true)]
[Guid("20AFACCC-E067-4AEF-AB6B-01A7E1396293")]
public enum HPCRunState
{
NotRunning = 0,
Initializing,
ClusterAllocating,
UploadingData,
Queued,
RunStarting,
WaitingForResults,
Complete,
}
[Guid("6CEDE8EC-A018-4F16-AF49-878B0F11382B")]
[ComVisible(true)]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface IHPCSettings
{
bool IsHPCConfigured { get; }
int NodeCount { get; }
int MaxNodeCount { get; }
HPCNodeSize InstanceType { get; }
int ThreadsPerTask { get; }
long ShutdownTimeTicks { get; }
//HPCEnvironments Environment { get; }
//double IdleTimeoutSeconds { get; }
//double ResponseTimeoutSeconds { get; }
}
#endif
[Guid("FAA2258A-3C52-4EB5-B65F-A7B6AE7E6CAE")]
[ComVisible(true)]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface IOpticalSystemTools
{
ISystemTool CurrentTool { get; }
int Progress { get; }
string Status { get; }
bool IsRunning { get; }
IBatchRayTrace OpenBatchRayTrace();
INSCRayTrace OpenNSCRayTrace();
IQuickAdjust OpenQuickAdjust();
IQuickFocus OpenQuickFocus();
ILightningTrace OpenLightningTrace();
IFindBestAsphere OpenFindBestAsphere();
IConvertAsphereType OpenConvertAsphereTypes();
ILocalOptimization OpenLocalOptimization();
IGlobalOptimization OpenGlobalOptimization();
IHammerOptimization OpenHammerOptimization();
ITolerancing OpenTolerancing();
IRestoreArchive OpenRestoreZAR();
ICreateArchive OpenCreateZAR();
IRestoreProject OpenRestoreProject();
ICreateProject OpenCreateProject();
IExportCAD OpenExportCAD();
IScale OpenScale();
IMFCalculator OpenMeritFunctionCalculator();
ILensCatalogs OpenLensCatalogs();
IConvertToNSCGroup OpenConvertToNSCGroup();
IDesignLockdown OpenDesignLockdown();
ICriticalRaysetGenerator OpenCriticalRaysetGenerator();
ISequenceSelector OpenSequenceSelector();
INSCQuickFocus OpenNSCQuickFocus();
bool RemoveAllVariables();
int SetAllRadiiVariable();
int SetAllThicknessesVariable();
double[] CreateDoubleVector(int numElements);
double[,] CreateDoubleMatrix(int Rows, int Cols);
IZRDReader OpenRayDatabaseReader();
IComputeRMSSpotSize OpenRMSSpotRadiusCalculator();
double GetConversionToSystemUnits(ZemaxSystemUnits fromUnits);
double GetConversionFromSystemUnits(ZemaxSystemUnits toUnits);
IShadedModelVisualizationExport OpenShadedModelVisualizationExport();
ILayouts Layouts { get; }
IMaterialsCatalog OpenMaterialsCatalog();
IQuickSensitivity OpenQuickSensitivity();
IToleranceDataViewer OpenToleranceDataViewer();
IRayAimingWizard OpenRayAimingWizard();
#if true
IHPCSettings GetHPCSettingsFromPrefs();
IHPCSettings GetHPCSettingsCustom(int nodeCount, HPCNodeSize instanceType);
INSCRayTrace OpenNSCRayTrace_HPC(IHPCSettings hpcSettings);
ITolerancing OpenTolerancing_HPC(IHPCSettings hpcSettings);
IGlobalOptimization OpenGlobalOptimization_HPC(IHPCSettings hpcSettings);
IHammerOptimization OpenHammerOptimization_HPC(IHPCSettings hpcSettings);
#endif
IPointTools GetPointTools();
IHullTools GetHullTools();
IFileManager OpenFileManager();
FileManager.IConvertProjectToFileTool OpenProjectToFileConverter();
IExportToSpeosLensSystem OpenExportToSpeosLensSystem();
IExportToSpeosWhitebox OpenExportToSpeosWhitebox();
IMessage LastError { get; }
IAPIUtilities GetUtilities();
IToleranceNest OpenNEST();
}
[ComVisible(true)]
[Guid("1E4AE725-1E9B-49F9-8E2A-E889A89557BE")]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface IAPIUtilities
{
string ConvertToStringFixed(double x, int digits);
string ConvertToStringFixed(double x);
string ConvertToStringExp(double x, int digits);
string ConvertToStringExp(double x);
string ConvertToStringCust(double x, int digits, double expBelow, double expAbove);
string ConvertToStringPref(double x);
}
[Guid("B8856163-1F74-47EC-94E4-18063856DDD0")]
[ComVisible(true)]
public enum RunStatus
{
Completed,
FailedToStart,
TimedOut,
InvalidTimeout
}
[Guid("E804D25D-924B-4EF8-9FAD-E3587119E9C8")]
[ComVisible(true)]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface ISystemTool
{
int Progress { get; }
string Status { get; }
bool IsRunning { get; }
bool CanCancel { get; }
bool IsAsynchronous { get; }
bool IsFiniteDuration { get; }
bool IsValid { get; }
bool Run();
bool RunAndWaitForCompletion();
bool WaitForCompletion();
bool Cancel();
bool Close();
RunStatus WaitWithTimeout(double timeOutSeconds);
RunStatus RunAndWaitWithTimeout(double timeOutSeconds);
bool Succeeded { get; }
string ErrorMessage { get; }
}
}
namespace ZOSAPI.Tools.General
{
[ComVisible(true)]
[Guid("ACB1A857-4FB8-4BF4-95E6-A0EE7FCB84C1")]
public enum QuickAdjustType
{
Radius,
Thickness,
}
[ComVisible(true)]
[Guid("2A654F7C-6A67-4CC2-A2C5-194F562F251D")]
public enum QuickAdjustCriterion
{
SpotSizeRadial = 0,
SpotSizeXOnly,
SpotSizeYOnly,
AngularRadial,
AngularXOnly,
AngularYOnly,
}
[Guid("6F19F415-7226-4E8D-BBB9-D5FEDCD9911D")]
[ComVisible(true)]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface IQuickAdjust : ISystemTool
{
int AdjustSurface { get; set; }
QuickAdjustType SurfaceParameter { get; set; }
QuickAdjustCriterion Criterion { get; set; }
int EvaluateSurface { get; set; }
void SetEvaluateSurfaceImage();
}
[ComVisible(true)]
[Guid("C91D936D-41FF-419B-B624-5590A7579930")]
public enum QuickFocusCriterion
{
SpotSizeRadial = 0,
SpotSizeXOnly,
SpotSizeYOnly,
RMSWavefront
}
[Guid("9BF20A54-8406-4443-8E45-9987D28D42D3")]
[ComVisible(true)]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface IQuickFocus : ISystemTool
{
bool UseCentroid { get; set; }
QuickFocusCriterion Criterion { get; set; }
}
[ComVisible(true)]
[Guid("53F6D976-ED38-4BBD-9570-1720F0D974EB")]
public enum ArchiveFileStatus
{
Okay = 0,
UnableToOpen = -1,
InvalidFile = -2,
InvalidVersion = -3,
}
[Guid("921BEA91-E126-4D0C-A3DF-3AB181F88C74")]
[ComVisible(true)]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface IRestoreArchive : ISystemTool
{
string ArchiveFile { get; }
ArchiveFileStatus SetFileName(string archiveFile);
string GetOutputFolder();
bool SetOutputFolder(string folder);
int NumberOfFilesInArchive { get; }
string GetFileNameInArchive(int fileNumber);
void SetFileOverwrite(int fileNumber, bool allowOverwrite);
void SetFilesAllOverwrite();
void SetFilesNoOverwrite();
bool ExtractAllFilesToProjectDirectory { get; set; }
}
[Guid("B7C8FF90-3EE7-47CD-9778-2E02454093E2")]
[ComVisible(true)]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface IRestoreProject : ISystemTool
{
string ArchiveFile { get; }
ArchiveFileStatus SetFileName(string archiveFile);
string GetOutputFolder();
bool SetOutputFolder(string folder);
int NumberOfFilesInArchive { get; }
string GetFileNameInArchive(int fileNumber);
void SetFileOverwrite(int fileNumber, bool allowOverwrite);
void SetFilesAllOverwrite();
void SetFilesNoOverwrite();
FileManager.IFile GetFile(int fileNumber);
bool UseProjectFile(int fileNumber);
bool UseRootFile(int fileNumber);
bool SetAllFilesToProject();
bool SetAllFilesToRoot();
int NumberOfAdditionalFiles { get; }
FileManager.IFile GetAdditionalFile(int addfileNumber);
}
[Guid("22A352DD-3F84-489C-BBC0-3E44A146389E")]
[ComVisible(true)]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface ICreateArchive : ISystemTool
{
string GetArchiveFileName();
bool SetArchiveFileName(string fullFileName);
bool UseDataCompression { get; set; }
}
[Guid("23EBE621-75C0-49A2-A54D-2C4F8EE9C2E6")]
[ComVisible(true)]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface ICreateProject : ISystemTool
{
string GetArchiveFileName();
bool SetArchiveFileName(string fullFileName);
bool UseDataCompression { get; set; }
}
[ComVisible(true)]
[Guid("95D029B0-DA8E-40E8-BDCD-B1DE168DFC40")]
public enum RayPatternType
{
XYFan = 0,
XFan,
YFan,
Ring,
List,
Random,
Grid,
SolidRing,
}
[ComVisible(true)]
[Guid("2674DE40-3DCE-4729-85AF-2B762DC3302E")]
public enum SplineSegmentsType
{
N_016 = 0,
N_032,
N_064,
N_128,
N_256,
N_512,
}
[ComVisible(true)]
[Guid("173EC09D-4A2C-46F5-AD19-F22FA82EE909")]
public enum CADFileType
{
IGES = 0,
STEP,
SAT,
STL,
SAB,
[Obsolete]
ASAT,
[Obsolete]
ASAB,
[Obsolete]
MODEL,
[Obsolete]
CATPART,
[Obsolete]
CATPRODUCT,
[Obsolete]
XCGM,
ZMO,
XT,
XB,
PRC,
JT,
N3MF,
U3D,
VRML,
OBJ,
}
[ComVisible(true)]
[Guid("7E7BA03D-9CAD-43AB-9153-F063154ABA4D")]
public enum CADToleranceType
{
N_TenEMinus4,
N_TenEMinus5,
N_TenEMinus6,
N_TenEMinus7,
}
[ComVisible(true)]
[Guid("917B6F8E-5682-41C3-A7D5-43E3BE366B81")]
public enum CADAngularToleranceType
{
Low = 0,
Medium,
High,
Presentation
}
[ComVisible(true)]
[Guid("D33C86F9-C05F-4D30-B5C2-14553EB0E4EB")]
public enum ACISExportVersion
{
Current = 0,
V25 = 1,
V26 = 2,
V27 = 3,
V28 = 4,
V29 = 5,
V30 = 6,
}
[Guid("CECE2EB0-93A7-45DC-9A68-E45C94BF9E30")]
[ComVisible(true)]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface IExportCAD : ISystemTool
{
int FirstSurface { get; set; }
int LastSurface { get; set; }
bool CanChangeSurface { get; }
int FirstObject { get; set; }
int LastObject { get; set; }
bool SequentialSettingsEnabled { get; }
RayPatternType RayPattern { get; set; }
int NumberOfRays { get; set; }
int Wavelength { get; set; }
void SetWavelengthAll();
int Field { get; set; }
void SetFieldAll();
bool DeleteVignetted { get; set; }
int RayLayer { get; set; }
int LensLayer { get; set; }
double DummyThickness { get; set; }
SplineSegmentsType SplineSegments { get; set; }
CADFileType FileType { get; set; }
CADToleranceType Tolerance { get; set; }
CADAngularToleranceType AngularTolerance { get; set; }
int Configuration { get; }
void SetSingleConfiguration(int ConfigurationNumber);
void SetCurrentConfiguration();
void SetConfigurationAllByLayer();
void SetConfigurationAllByFile();
void SetConfigurationAllAtOnce();
bool ExportDummySurfaces { get; set; }
bool SurfacesAsSolids { get; set; }
bool ScatterNSCRays { get; set; }
bool SplitNSCRays { get; set; }
bool UsePolarization { get; set; }
string OutputFileName { get; set; }
bool AutoNameFaces { get; set; }
ACISExportVersion FileVersion { get; set; }
bool ExportRayFootprint { get; set; }
int RayFootprintLayer { get; set; }
bool ExportChiefRay { get; set; }
string RayFilter { get; set; }
}
[Guid("0C88274C-ED4D-4522-A8FC-EE0B266AC598")]
[ComVisible(true)]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface ILensCatalogs : ISystemTool
{
string SelectedVendor { get; set; }
string[] GetAllVendors();
bool UseEFL { get; set; }
double MinEFL { get; set; }
double MaxEFL { get; set; }
bool UseEPD { get; set; }
double MinEPD { get; set; }
double MaxEPD { get; set; }
bool IncShapeEqui { get; set; }
bool IncShapeBi { get; set; }
bool IncShapePlano { get; set; }
bool IncShapeMeniscus { get; set; }
bool IncTypeSpherical { get; set; }
bool IncTypeGRIN { get; set; }
bool IncTypeAspheric { get; set; }
bool IncTypeToroidal { get; set; }
int NumberOfElements { get; set; }
void SetNumberOfElementsAny();
int MatchingLenses { get; }
int LensesForVendor { get; }
ILensCatalogLens GetResult(int index);
}
[Guid("91B9FBD2-AC88-4615-8211-81203EB02959")]
[ComVisible(true)]
public enum LensShape
{
Unknown,
Equi,
Bi,
Plano,
Meniscus,
}
[Guid("9D857501-EFB7-42E3-9F73-334A47717966")]
[ComVisible(true)]
public enum LensType
{
Other,
Spherical,
GRIN,
Aspheric,
Toroidal
}
[Guid("1A13E4E5-7393-450B-B7A3-8C2A4AA1420A")]
[ComVisible(true)]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface ILensCatalogLens
{
string Vendor { get; }
string LensName { get; }
double EFL { get; }
double EPD { get; }
LensShape Shape { get; }
LensType Type { get; }
int NumberOfElements { get; }
bool Telecentric { get; }
void LoadLens(bool saveIfNeeded);
IOpticalSystem LoadNewLensSeq();
IOpticalSystem LoadNewLensNonSeq();
bool InsertLensSeq(int atSurface, bool ignoreObject, bool reverseSurfGeom);
bool InsertLensNonSeq();
}
[Guid("9991F9C5-7EE6-49F0-96DD-7B8CFB65F7A7")]
[ComVisible(true)]
public enum ScaleToUnits
{
Millimeters,
Centimeters,
Inches,
Meters,
}
[Guid("6517C7CA-303F-4D9B-BEF1-96FCEBA55AC0")]
[ComVisible(true)]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface IScale : ISystemTool
{
double ScaleFactor { get; set; }
int FirstComponent { get; set; }
int LastComponent { get; set; }
ScaleToUnits ScaleToUnit { get; set; }
bool ScaleByFactor { get; set; }
bool ScaleByUnits { get; set; }
int NumberOfComponents { get; }
string GetComponentAt(int idx);
}
[Guid("2935EC13-970D-4C33-90D1-9870AD5630CA")]
[ComVisible(true)]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface IComputeRMSSpotSize : ISystemTool
{
bool UseGaussianQuadrature { get; }
bool UseRectangularArray { get; }
int NumberOfRings { get; }
int NumberOfArms { get; }
double ObscuredFration { get; }
int GridSampling { get; }
bool DeleteVignetted { get; }
bool AssumeAxialSymmetry { get; set; }
bool IgnoreLateralColor { get; set; }
void SetMethodGaussianQuadrature(int numberOfRings, int numberOfArms, double obscuredFraction);
void SetMethodRectangularArray(int gridSampling, bool deleteVignetted);
int NumberOfConfigurations { get; }
int NumberOfFields { get; }
double[,] RMSSpotRadii { get; }
double GetSpotRadius(int configuration, int field);
}
[Guid("D0D8F0F6-5AEB-4C71-ADDD-2678C7A7E6C7")]
[ComVisible(true)]
public enum EntryCompressionModes
{
Auto = 0,
On = 1,
Off = 2,
}
[Guid("C24D664D-8FEA-4642-9D14-4A4F0548B350")]
[ComVisible(true)]
public enum ZemaxFileTypes
{
Unknown = 0,
LMX = 1,
User = 2,
}
[Guid("EA46086C-21AA-4F5D-AC59-36A1D0CE7BA5")]
[ComVisible(true)]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface IDataDictionary
{
string FileName { get; }
ZemaxFileTypes FileType { get; }
int FileVersion { get; }
int FileData1 { get; }
int FileData2 { get; }
string[] Keys { get; }
string GetKey(int keyIndex);
int NumberOfEntries { get; }
IDataEntry[] Entries { get; }
IDataEntry GetEntry(string key);
IDataEntry CreateEntry(string key);
void Save();
void Close();
}
[Guid("14DD67CF-1442-418F-93E5-58C1DDC1D0C6")]
[ComVisible(true)]
public enum DataTypes : short
{
NotSet,
Boolean,
Integer,
IntegerArray,
IntegerMatrix,
Float,
FloatArray,
FloatMatrix,
Double,
DoubleArray,
DoubleMatrix,
String,
StringArray,
StringMatrix,
ByteArray,
Dictionary,
Serializable,
File,
}
[Guid("D85B2EF6-6AB0-4C8C-BC5F-BD90BB93AB71")]
[ComVisible(true)]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface IDataEntry
{
DataTypes DataType { get; }
bool IsSet { get; }
string Key { get; }
EntryCompressionModes CompressionMode { get; set; }
void Delete();
// TODO - 'Safe' methods for COM
bool GetBooleanValue();
int GetIntegerValue();
int[] GetIntegerArray();
int[,] GetIntegerMatrix();
float GetFloatValue();
float[] GetFloatArray();
float[,] GetFloatMatrix();
double GetDoubleValue();
double[] GetDoubleArray();
double[,] GetDoubleMatrix();
string GetStringValue();
string[] GetStringArray();
string[,] GetStringMatrix();
byte[] GetByteArray();
//IDataDictionary GetDictionaryValue();
Object GetSerializableValue();
void GetFile(string fileName);
bool SetBooleanValue(bool val);
bool SetIntegerValue(int val);
bool SetIntegerArray(int[] val);
bool SetIntegerMatrix(int[,] val);
bool SetFloatValue(float val);
bool SetFloatArray(float[] val);
bool SetFloatMatrix(float[,] val);
bool SetDoubleValue(double val);
bool SetDoubleArray(double[] val);
bool SetDoubleMatrix(double[,] val);
bool SetStringValue(string val);
bool SetStringArray(string[] val);
bool SetStringMatrix(string[,] val);
bool SetByteArray(byte[] val);
//bool SetDictionaryValue(IDataDictionary val);
bool SetSerializableValue(Object val);
bool SetFile(string fileName);
}
public interface IPoint3D
{
double X { get; set; }
double Y { get; set; }
double Z { get; set; }
void Add(IPoint3D p);
double GetDim(int Dim);
void SetDim(int Dim, double Value);
int[] GetSortedDims();
double Magnitude();
double MagnitudeSq();
bool VectorAndScalar(out IPoint3D Vector, out double Scalar);
}
public interface IPointList3D
{
int NumberOfPoints { get; }
IPoint3D GetPoint(int Index);
void AddPoint(IPoint3D p);
void AddPoint(double X, double Y, double Z);
void RemovePoint(int Index);
void Clear();
}
public interface IPointTools
{
IPointList3D CreatePointList();
IPoint3D CreatePoint(double x, double y, double z);
IPoint3D Add(IPoint3D p1, IPoint3D p2);
IPoint3D Subtract(IPoint3D p1, IPoint3D p2);
IPoint3D Cross(IPoint3D p1, IPoint3D p2);
IPoint3D Multiply(IPoint3D p, double s);
IPoint3D Divide(IPoint3D p, double s);
double Dot(IPoint3D p1, IPoint3D p2);
IPoint3D ComputeCentroid(IPointList3D points);
}
public interface ICovarianceData
{
double[,] Cov { get; }
double[,] V { get; }
double[] W { get; }
IMatrixData GetCovariance();
IMatrixData GetVectors();
IVectorData GetValues();
}
public interface IHullTools
{
ICovarianceData ComputeCovData(IPointList3D points, IPoint3D center);
IPointList3D Compute2DHull(IPointList3D points, IPoint3D planeOrigin, IPoint3D planeX, IPoint3D planeY);
}
[Guid("3BA879AC-4544-498B-B6AC-B57650A7C00A")]
[ComVisible(true)]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface IRayAimingWizard : ISystemTool
{
void ApplyRecommendedSettings();
ISDRayAimingData GetRecommendedSettings();
}
}