Skip to main content

ZOS-API interface 2024 R2 SP02

ZOSAPI.Common.IVectorData Interface Reference

Last update: 17.07.2025

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

Public Member Functions

void ReadData (int Size, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex=0)][In, Out]double[] Data)
 Populates the specified array with the data vector. Note that this is the same as using the Data property, however it may be easier to use for COM-based clients.
 
void WriteData (int Size, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex=0)][In]double[] Data)
 Stores the specified array in the vector. Note that this is the same as using the Data property, however it may be easier to use for COM-based clients. This method will not do anything if IsReadOnly is true.
 
double GetValueAt (int position)
 Gets the value at the specified index. Note that this may be much slower than retrieving all of the data at once via the Data property or ReadData method.
 
void SetValueAt (int position, double Value)
 Sets the value at the specified position. Note that this may be much slower than setting all of the data at once via the Data property or WriteData method.
 

Properties

bool IsReadOnly [get]
 Gets a value indicating whether the data in this vector can be modified.
 
int Length [get]
 Gets the length of this data vector.
 
double[] Data [get, set]
 Gets or sets the data for this vector.
 

Detailed Description

Methods and properties for retrieving and/or setting a 1D 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.IVectorData.GetValueAt ( int  position)

Gets the value at the specified index. Note that this may be much slower than retrieving all of the data at once via the Data property or ReadData method.

Parameters
positionThe position (0 to Length-1).
Returns

◆ ReadData()

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

Populates the specified array with the data vector. Note that this is the same as using the Data property, however it may be easier to use for COM-based clients.

Parameters
SizeThe size of the input array.
DataThe array to fill.

◆ SetValueAt()

void ZOSAPI.Common.IVectorData.SetValueAt ( int  position,
double  Value 
)

Sets the value at the specified position. Note that this may be much slower than setting all of the data at once via the Data property or WriteData method.

Parameters
positionThe position (0 to Length-1).
ValueThe new value.

◆ WriteData()

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

Stores the specified array in the vector. Note that this is the same as using the Data property, however it may be easier to use for COM-based clients. This method will not do anything if IsReadOnly is true.

Parameters
SizeThe size of the input array.
DataThe data to store.

Property Documentation

◆ Data

double [] ZOSAPI.Common.IVectorData.Data
getset

Gets or sets the data for this vector.

Usage (see Example 04 for a full sample)

C#

// Read data series
System.Text.StringBuilder sbReport = new System.Text.StringBuilder();
sbReport.Append("X Data\t");
for (int i = 0; i < newWin_Results.NumberOfDataSeries; i++)
{
sbReport.Append("Series " + i + "\t\t");
}
sbReport.AppendLine("");
for (int k = 0; k < newWin_Results.GetDataSeries(0).XData.Length; k++)
{
sbReport.Append(newWin_Results.GetDataSeries(0).XData.GetValueAt(k) + "\t");
for (int i = 0; i < newWin_Results.NumberOfDataSeries; i++)
{
for (int j = 0; j < newWin_Results.GetDataSeries(i).NumSeries; j++)
{
sbReport.Append(newWin_Results.GetDataSeries(i).YData.GetValueAt(k, j) + "\t");
}
}
sbReport.AppendLine("");
}
string resFile = TheApplication.SamplesDir + "\\API\\CS\\e04_pull_data_from_FFTMT.txt";
System.IO.File.WriteAllText(resFile, sbReport.ToString());

C++

// Export the data series to a text file
fstream textfile;
string filepath = sampleDir + "\\API\\CPP\\e04_pull_data_from_FFTMTF.txt";
textfile.open(filepath, fstream::trunc | ios::out);
for (int i = 0; i < newWin_Results->NumberOfDataSeries; i++) {
IAR_DataSeriesPtr dataseries = newWin_Results->GetDataSeries(i);
for (int j = 0; j < dataseries->NumSeries; j++) {
textfile << "\nSeries " << i << " - " << j << " : (X, Y)" << endl;
for (int k = 0; k < dataseries->GetXData()->Length; k++) {
textfile << dataseries->GetXData()->GetValueAt(k) << "\t";
textfile << dataseries->GetYData()->GetValueAt(k, j) << endl;
}
}
}

Matlab

% Read and plot data series
dataSeries = newWin_Results.DataSeries;
cc=lines(double(newWin_Results.NumberOfDataSeries));
for gridN=1:newWin_Results.NumberOfDataSeries
data = dataSeries(gridN);
y = data.YData.Data.double;
x = data.XData.Data.double;
plot(x,y(:,1),'-','color',cc(gridN,:));
plot(x,y(:,2),':','color',cc(gridN,:));
end

Python

# Read and plot data series
# NOTE: numpy functions are used to unpack and plot the 2D tuple for Sagittal & Tangential MTF
# You will need to import the numpy module to get this part of the code to work
colors = ('b','g','r','c', 'm', 'y', 'k')
for seriesNum in range(0,newWin_Results.NumberOfDataSeries, 1):
data = newWin_Results.GetDataSeries(seriesNum)
# get raw .NET data into numpy array
xRaw = data.XData.Data
yRaw = data.YData.Data
x = list(xRaw)
y = zos.reshape(yRaw, yRaw.GetLength(0), yRaw.GetLength(1), True)
plt.plot(x,y[0],color=colors[seriesNum])
plt.plot(x,y[1],linestyle='--',color=colors[seriesNum])

The data.

◆ IsReadOnly

bool ZOSAPI.Common.IVectorData.IsReadOnly
get

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

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

◆ Length

int ZOSAPI.Common.IVectorData.Length
get

Gets the length of this data vector.

The length.

Connect with Ansys