Skip to main content

ZOS-API interface 2024 R1

ZOSAPI.Common.IMatrixData Interface Reference

Last update: 17.07.2025

Methods and properties for retrieving and/or setting a 2D array of double precision data. More...

Public Member Functions

void ReadData (int Size, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex=0)][In, Out]double[] Data)
 Retrieve the entire data set. This method is functionally identical to using Data, however it may be easier to use from some languages.
 
void WriteData (int Size, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex=0)][In]double[] Data)
 Update the entire data set. This method is functionally identical to using Data, however it may be easier to use from some languages.
Note that calling this method will have no effect if IsReadOnly is true.
 
double GetValueAt (int Row, int Col)
 Retrieves a single value from the 2D array. Note that accessing the data one element at a time may be much slower than retrieving the entire array at once.
 
void SetValueAt (int Row, int Col, double Value)
 Set a single value from the 2D array. Note that accessing the data one element at a time may be much slower than updating the entire array at once.
 

Properties

bool IsReadOnly [get]
 Gets a value indicating whether the data in this matrix can be modified.
 
int Rows [get]
 Gets the number of rows in the 2D array.
 
int Cols [get]
 Gets the number of cols in the 2D array.
 
int TotalLength [get]
 Gets the total size of the 2D array (Rows * Cols).
 
double[,] Data [get, set]
 Gets or sets (if IsReadOnly is false) the data. Note that making changes to the returned array does not change the underlying data source.
Use this property to replace the entire data, or use WriteData to update the data source.
 

Detailed Description

Methods and properties for retrieving and/or setting a 2D array of double precision data.

Usage (see Example 23 for a full sample)

C#

// runs a ray fan analysis and extracts
ZOSAPI.Analysis.IA_ ray = TheSystem.Analyses.New_Analysis(ZOSAPI.Analysis.AnalysisIDM.RayFan);
ray_settings.NumberOfRays = max_rays / 2;
ray_settings.Field.UseAllFields();
ray_settings.Wavelength.UseAllWavelengths();
Properties and methods for retrieving analysis window data. This interface can be accessed via the IA...
Definition: IAR_Base.cs:21
Base interface for all analysis windows. This interface can be accessed via the I_Analyses interface.
Definition: IA_Base.cs:29
IAR_ GetResults()
Gets the result data (if available) for the current analysis.
IAS_ GetSettings()
Gets the settings for the current analysis.
IMessage ApplyAndWaitForCompletion()
Re-runs the analysis with the current settings and waits for it to finish calculating.
Definition: IAS_Fan.cs:24
IAS_Wavelength Wavelength
Definition: IAS_Fan.cs:27
IAS_Field Field
Definition: IAS_Fan.cs:25
Definition: IAS_Fan.cs:5
Definition: IAS_FieldCurvatureAndDistortion.cs:5
Definition: IAS_FieldCurvatureAndDistortion.cs:5
The ZOSAPI namespace contains classes for initially connecting to zemax. See also ZOSAPI_Connection,...
Definition: IAS_FieldCurvatureAndDistortion.cs:5

C++

// Set up Ray Fan analysis
IA_Ptr ray = TheSystem->Analyses->New_Analysis(AnalysisIDM_RayFan);
IAS_Ptr ray_set = ray->GetSettings();
IAS_FanPtr ray_fanset = ray_set;
ray_fanset->NumberOfRays = max_rays / 2;
ray_fanset->Field->UseAllFields();
ray_fanset->Wavelength->UseAllWavelengths();
ray->ApplyAndWaitForCompletion();
IAR_Ptr ray_results = ray->GetResults();

Matlab

% runs a ray fan analysis and extracts
ray = TheSystem.Analyses.New_Analysis(ZOSAPI.Analysis.AnalysisIDM.RayFan);
ray_settings = ray.GetSettings();
ray_settings.NumberOfRays = max_rays / 2;
ray_settings.Field.UseAllFields();
ray_settings.Wavelength.UseAllWavelengths();
ray.ApplyAndWaitForCompletion();
ray_results = ray.GetResults();

Python

ray = TheSystem.Analyses.New_Analysis(ZOSAPI.Analysis.AnalysisIDM.RayFan)
ray_settings = ray.GetSettings()
ray_settings.NumberOfRays = max_rays / 2
ray_settings.Field.UseAllFields()
ray_settings.Wavelength.UseAllWavelengths()
ray.ApplyAndWaitForCompletion()
ray_results = ray.GetResults()

Member Function Documentation

◆ GetValueAt()

double ZOSAPI.Common.IMatrixData.GetValueAt ( int  Row,
int  Col 
)

Retrieves a single value from the 2D array. Note that accessing the data one element at a time may be much slower than retrieving the entire array at once.

Parameters
RowThe row.
ColThe col.
Returns

◆ ReadData()

void ZOSAPI.Common.IMatrixData.ReadData ( int  Size,
[In, Out] double[]  Data 
)

Retrieve the entire data set. This method is functionally identical to using Data, however it may be easier to use from some languages.

Parameters
SizeThe size of the input array – this must be the same as TotalLength.
DataThe array to fill. Note that this must be allocated prior to calling ReadData.

◆ SetValueAt()

void ZOSAPI.Common.IMatrixData.SetValueAt ( int  Row,
int  Col,
double  Value 
)

Set a single value from the 2D array. Note that accessing the data one element at a time may be much slower than updating the entire array at once.

Parameters
RowThe row.
ColThe col.
ValueThe value.

◆ WriteData()

void ZOSAPI.Common.IMatrixData.WriteData ( int  Size,
[In] double[]  Data 
)

Update the entire data set. This method is functionally identical to using Data, however it may be easier to use from some languages.
Note that calling this method will have no effect if IsReadOnly is true.

Parameters
SizeThe size of the input array.
DataThe new array data.

Property Documentation

◆ Cols

int ZOSAPI.Common.IMatrixData.Cols
get

Gets the number of cols in the 2D array.

The number of cols.

◆ Data

double [,] ZOSAPI.Common.IMatrixData.Data
getset

Gets or sets (if IsReadOnly is false) the data. Note that making changes to the returned array does not change the underlying data source.
Use this property to replace the entire data, or use WriteData to update the data source.

The raw array of data.

◆ IsReadOnly

bool ZOSAPI.Common.IMatrixData.IsReadOnly
get

Gets a value indicating whether the data in this matrix can be modified.

true if this instance is read only; otherwise, false.

◆ Rows

int ZOSAPI.Common.IMatrixData.Rows
get

Gets the number of rows in the 2D array.

The number of rows.

◆ TotalLength

int ZOSAPI.Common.IMatrixData.TotalLength
get

Gets the total size of the 2D array (Rows * Cols).

The total length.

Connect with Ansys