Skip to main content

ZOS-API interface 2024 R1

ZOSAPI.Editors.NCE.INonSeqEditor Interface Reference

Last update: 17.07.2025

This interface defines all properties and methods needed to interact with the Non-Sequential Component Editor. This interface can be accessed via the IOpticalSystem interface. More...

Inheritance diagram for ZOSAPI.Editors.NCE.INonSeqEditor:

Public Member Functions

string[] AllAvailableObjectNames ()
 
string[] AvailableSourceNames ()
 
string[] AvailableDetectorNames ()
 
string[] AvailableObjectNames ()
 
ObjectType ObjectTypeFromObjectName (string objectName)
 
string ObjectNameFromObjectType (ObjectType objectType)
 
bool SetActiveSurface (int SurfaceNumber)
 Sets theActiveSurface to the specified surface.
 
bool NextNSCGroup ()
 Selects the next available non-sequential surface.
 
bool PrevNSCGroup ()
 Selects the previous available non-sequential surface.
 
INCERow GetObjectAt (int ObjectNumber)
 Gets the object at the specified position.
 
INCERow InsertNewObjectAt (int ObjectNumber)
 Inserts a new object at the specified position.
 
INCERow AddObject ()
 Adds a new object as the last object in the system.
 
bool RemoveObjectAt (int ObjectNumber)
 Removes the object at the specified location.
 
int RemoveObjectsAt (int ObjectNumber, int numObjects)
 Removes one or more objects at the specified location.
 
void ReloadObject (int ObjectNumber)
 Reloads the specified object (for more information, see the OpticStudio manual).
 
void ReloadAllObjects ()
 Reloads all objects in the editor (for more information, see the OpticStudio manual).
 
bool ShowNCE ()
 Shows this editor in the UI. Note that this only has an effect if the IOpticalSystem.Mode is ZOSAPI_Mode.Plugin.
 
void HideNCE ()
 Closes this editor in the UI. Note that this only has an effect if the IOpticalSystem.Mode is ZOSAPI_Mode.Plugin.
 
bool GetMatrix (int ObjectNumber, out double R11, out double R12, out double R13, out double R21, out double R22, out double R23, out double R31, out double R32, out double R33, out double Xo, out double Yo, out double Zo)
 Get the rotation and position matrices for NSC objects relative to the NSC surface origin.
 
bool GetDetectorDimensions (int ObjectNumber, out uint Rows, out uint Cols)
 Gets the dimensions of the specified detector.
 
bool GetCoherentData (int ObjectNumber, int pixel, DetectorDataType Data, out double Value)
 Gets data from a NSC detector.
 
double[,] GetAllCoherentDataSafe (int ObjectNumber, DetectorDataType Data)
 Gets data from a NSC detector for all pixels.
 
bool GetAllCoherentData (int ObjectNumber, DetectorDataType Data, uint numPixels, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex=2)][In, Out]double[] detectorData)
 Gets data from a NSC detector for all pixels.
 
uint GetDetectorSize (int ObjectNumber)
 Gets the total number of pixels for the specified detector.
 
bool GetDetectorData (int ObjectNumber, int pixel, int Data, out double Value)
 Gets data from a NSC detector.
 
bool GetAllDetectorData (int ObjectNumber, int Data, uint numPixels, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex=2)][In, Out]double[] detectorData)
 Similar to GetDetectorData, but retrieves data for all pixels at once.
 
double[,] GetAllDetectorDataSafe (int ObjectNumber, int Data)
 Similar to GetDetectorData, but retrieves data for all pixels at once.
 
bool GetPolarDetectorData (int ObjectNumber, int pixel, PolarDetectorDataType Data, out double Value)
 Gets data from a NSC detector.
 
bool GetAllPolarDetectorData (int ObjectNumber, PolarDetectorDataType Data, uint numPixels, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex=2)][In, Out]double[] detectorData)
 Similar to GetDetectorData, but retrieves data for all pixels at once.
 
double[,] GetAllPolarDetectorDataSafe (int ObjectNumber, PolarDetectorDataType Data)
 Similar to GetDetectorData, but retrieves data for all pixels at once.
 
bool LoadDetector (int ObjectNumber, string fileName, bool appendData)
 Loads the data saved in a file to an NSC Detector Rectangle, Detector Color, Detector Polar, or Detector Volume object.
 
bool SaveDetector (int ObjectNumber, string fileName)
 Saves the data currently on an NSC Detector Rectangle, Detector Color, Detector Polar, or Detector Volume object to a file.
 
int CopyObjects (int fromObjectNumber, int NumberOfObjects, int toObjectNumber)
 Copy and paste the specified number of objects from one location to another. Note that it is okay for the source and destination to overlap.
 
int CopyObjectsFrom (INonSeqEditor fromEditor, int fromObjectNumber, int NumberOfObjects, int toObjectNumber)
 Copy and paste the specified number of objects from one location (in the specified system) to another location (in this system). Note that it is okay for the source and destination to overlap.
 
bool GetColorDetectorData (int ObjectNumber, int pixel, bool angleSpace, int Data, int numIgnoredPixels, double Wavelength, out double Value)
 Gets data from a NSC Detector Color.
 
bool GetAllColorDetectorData (int ObjectNumber, bool angleSpace, int Data, uint numPixels, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex=2)][In, Out]double[] detectorData)
 Similar to GetColorDetectorData, but retrieves data for all pixels at once.
 
double[,] GetAllColorDetectorDataSafe (int ObjectNumber, bool angleSpace, int Data)
 Similar to GetColorDetectorData, but retrieves data for all pixels at once.
 
IMessage ModifyReferenceObjects (int first, int last, int reference)
 ModifyReferenceObjects modifies objects numbered first through last according to reference by
  • updating each selected object's reference object and
  • updating the position and rotation angle for each object to retain its current position and orientation.

 
bool GetGlass (int ObjectNumber, out string glassName, out double nd, out double vd, out double dpgf)
 Retrieve data about the glass on any object.
 
int GetIndex (int ObjectNumber, int NumberOfWavelengths, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex=1)][In, Out]double[] indexAtWavelength)
 Extract refraction data for any object.
 
string GetClosestGlass (int ObjectNumber)
 Get the closest catalog glass to the model glass on the specified object. Note that this should only be called for an object that uses a model glass solve, otherwise the result is undefined.
 
long GetId (int objectNumber)
 
IMessage ReplicateObject (int ObjectNumber, int NumX, int NumY, int NumZ, double DeltaX, double DeltaY, double DeltaZ, bool AddPickupSolves, bool RelativeReferences)
 Replicate the selected object on x, y, and z arrays.
 
- Public Member Functions inherited from ZOSAPI.Editors.IEditor
IEditorRow GetRowAt (int pos)
 Gets the row at the specified index (0 to NumberOfRows-1).
 
IEditorRow InsertRowAt (int pos)
 Inserts a new row at the specified index (0 to NumberOfRows). Note that some editors - such as the Lens Data Editor may not allow inserting new rows before the first row.
 
IEditorRow AddRow ()
 Adds a new row at the end of the editor.
 
bool DeleteRowAt (int pos)
 Deletes a row at the specified index (0 to NumberOfRows-1). Note that all editors require at least one row, and some editors may require more than that.
 
int DeleteRowsAt (int pos, int numberOfRows)
 Deletes one or more rows at the specified index (0 to NumberOfRows-1).
 
int DeleteAllRows ()
 Deletes all rows from the current editor.
 
bool ShowEditor ()
 Shows this editor in the UI. Note that this only has an effect if the IOpticalSystem.Mode is ZOSAPI_Mode.Plugin.
 
void HideEditor ()
 Closes this editor in the UI. Note that this only has an effect if the IOpticalSystem.Mode is ZOSAPI_Mode.Plugin.
 

Properties

int RowToObjectOffset [get]
 Gets the offset from a row to a object (always 1).
 
int ActiveSurface [get]
 Gets the active non-sequential surface number for the current INonSeqEditor instance.
 
int NumberOfObjects [get]
 Gets the number of objects on the current non-sequential component group.
 
ObjectColumn FirstColumn [get]
 Gets the first available column.
 
ObjectColumn LastColumn [get]
 Gets the last available column.
 
- Properties inherited from ZOSAPI.Editors.IEditor
EditorType Editor [get]
 Gets the type of this editor instance.
 
int NumberOfRows [get]
 Gets the number of rows in this editor. Note that this referes to surfaces, objects, or operands depending on editor type.
 
int MinColumn [get]
 The minimum column index that can be used in calls to IEditorRow.GetCellAt for any IEditorRow retrieved from this editor.
 
int MaxColumn [get]
 The maximum column index that can be used in calls to IEditorRow.GetCellAt for any IEditorRow retrieved from this editor.
 

Detailed Description

Member Function Documentation

◆ AddObject()

INCERow ZOSAPI.Editors.NCE.INonSeqEditor.AddObject ( )

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

Usage (see Example 21 for a full sample)

C#

// Add 4 more objects
INonSeqEditor TheNCE = TheSystem.NCE;
TheNCE.AddObject();
TheNCE.AddObject();
TheNCE.AddObject();
TheNCE.AddObject();
This interface defines all properties and methods needed to interact with the Non-Sequential Componen...
Definition: InterfacesNCE.cs:363
INCERow AddObject()
Adds a new object as the last object in the system.

C++

// Add 4 more objects
INonSeqEditorPtr TheNCE = TheSystem->NCE;
TheNCE->AddObject();
TheNCE->AddObject();
TheNCE->AddObject();
TheNCE->AddObject();

Matlab

% Add 4 more objects
TheNCE = TheSystem.NCE;
TheNCE.AddObject();
TheNCE.AddObject();
TheNCE.AddObject();
TheNCE.AddObject();

Python

# Add 4 more objects
TheNCE = TheSystem.NCE
TheNCE.AddObject()
TheNCE.AddObject()
TheNCE.AddObject()
TheNCE.AddObject()
Returns
Examples
CSharpStandalone_21_White_LED_Phosphor.cs.

◆ AllAvailableObjectNames()

string[] ZOSAPI.Editors.NCE.INonSeqEditor.AllAvailableObjectNames ( )

◆ AvailableDetectorNames()

string[] ZOSAPI.Editors.NCE.INonSeqEditor.AvailableDetectorNames ( )

◆ AvailableObjectNames()

string[] ZOSAPI.Editors.NCE.INonSeqEditor.AvailableObjectNames ( )

◆ AvailableSourceNames()

string[] ZOSAPI.Editors.NCE.INonSeqEditor.AvailableSourceNames ( )

◆ CopyObjects()

int ZOSAPI.Editors.NCE.INonSeqEditor.CopyObjects ( int  fromObjectNumber,
int  NumberOfObjects,
int  toObjectNumber 
)

Copy and paste the specified number of objects from one location to another. Note that it is okay for the source and destination to overlap.

Parameters
fromObjectNumberFirst object number to copy (1 to NumberOfObjects).
NumberOfObjectsThe number of objects to copy.
toObjectNumberRow to start inserting the objects (1 to NumberOfObjects+1).
Returns
The number of objects actually copied.

◆ CopyObjectsFrom()

int ZOSAPI.Editors.NCE.INonSeqEditor.CopyObjectsFrom ( INonSeqEditor  fromEditor,
int  fromObjectNumber,
int  NumberOfObjects,
int  toObjectNumber 
)

Copy and paste the specified number of objects from one location (in the specified system) to another location (in this system). Note that it is okay for the source and destination to overlap.

Parameters
fromEditorSystem to copy the objects from.
fromObjectNumberFirst object number to copy (1 to NumberOfObjects).
NumberOfObjectsThe number of objects to copy.
toObjectNumberTo object number (1 to NumberOfObjects+1).
Returns
The number of objects actually copied.

◆ GetAllCoherentData()

bool ZOSAPI.Editors.NCE.INonSeqEditor.GetAllCoherentData ( int  ObjectNumber,
DetectorDataType  Data,
uint  numPixels,
[In, Out] double[]  detectorData 
)

Gets data from a NSC detector for all pixels.

Usage (see Example 08 for a full sample)

C++

// Retrieve whole data array with GetAllCoherentDataSafe(), or GetAllCoherentData().
// Safe arrays are cumbersome in C++, so use GetAllCoherentData() here.
// The 'Data' input functions similarly to NSDC(real, imaginary, amplitude, power)
// Note: divide coherent power by pixel area to get coherent irradiance.
double* DetRectangleData_CoherentPower = new double[14400]; // coherent power on each pixel
bool SuccessCoherentPow = TheSystem->NCE->GetAllCoherentData(4, DetectorDataType::DetectorDataType_Power, 14400, DetRectangleData_CoherentPower);
Parameters
ObjectNumberThe object number of the detector.
DataThe desired data type.
numPixelsThe number of pixels in the data array; this should match the value returned by GetDetectorSize.
detectorDataThe data array to fill with the desired data.
Returns
true for a valid detector; false otherwise

◆ GetAllCoherentDataSafe()

double[,] ZOSAPI.Editors.NCE.INonSeqEditor.GetAllCoherentDataSafe ( int  ObjectNumber,
DetectorDataType  Data 
)

Gets data from a NSC detector for all pixels.

Usage (see Example 24 for a full sample)

C#

// Saves current system in memory
TheSystem.SaveAs(TheApplication.SamplesDir + "\\API\\CS\\e24_nsc_detectors.zos");

C++

// saves current system in memory
TheSystem->SaveAs((_bstr_t)TheApplication->SamplesDir + "\\API\\CPP\\e24_nsc_detectors.zos");

Matlab

% saves current system in memory
TheSystem.Save();

Python

# saves current system in memory
TheSystem.Save()
Parameters
ObjectNumberThe object number of the detector.
DataThe desired data type.
Returns
2D array of the desired data for valid inputs; null otherwise.

◆ GetAllColorDetectorData()

bool ZOSAPI.Editors.NCE.INonSeqEditor.GetAllColorDetectorData ( int  ObjectNumber,
bool  angleSpace,
int  Data,
uint  numPixels,
[In, Out] double[]  detectorData 
)

Similar to GetColorDetectorData, but retrieves data for all pixels at once.

Parameters
ObjectNumberThe object number of the detector.
angleSpaceGetColorDetectorData
DataGetColorDetectorData
numPixelsThe number of pixels in the data array; this should match the value returned by GetDetectorSize.
detectorDataThe data array to fill with the desired data.
Returns
true for a valid detector; false otherwise

◆ GetAllColorDetectorDataSafe()

double[,] ZOSAPI.Editors.NCE.INonSeqEditor.GetAllColorDetectorDataSafe ( int  ObjectNumber,
bool  angleSpace,
int  Data 
)

Similar to GetColorDetectorData, but retrieves data for all pixels at once.

Parameters
ObjectNumberThe object number of the detector.
angleSpaceGetColorDetectorData
DataGetColorDetectorData
Returns
The requested data for a valid detector; null otherwise

◆ GetAllDetectorData()

bool ZOSAPI.Editors.NCE.INonSeqEditor.GetAllDetectorData ( int  ObjectNumber,
int  Data,
uint  numPixels,
[In, Out] double[]  detectorData 
)

Similar to GetDetectorData, but retrieves data for all pixels at once.

Usage (see Example 02 for a full sample)

C#

// Get detector data
System.Text.StringBuilder sbReport = new System.Text.StringBuilder();
double[,] detectorData = new double[100, 100];
for (int i = 0; i < 99; i++)
{
for (int j = 0; j < 99; j++)
{
TheNCE.GetDetectorData(4, j + i * 100, 1, out detectorData[i, j]);
sbReport.Append(detectorData[i, j].ToString() + "\t");
}
sbReport.AppendLine("");
}
string resFile = TheApplication.SamplesDir + "\\API\\CS\\e02_NSC_ray_trace.txt";
System.IO.File.WriteAllText(resFile, sbReport.ToString());

C++

// Get detector data
double detectorData[100][100];
for (int i = 0; i < 99; i++)
for (int j = 0; j < 99; j++)
TheNCE->GetDetectorData(4, j + i * 100, 1, &detectorData[i][j]);

Matlab

% Get detector data
data = NET.createArray('System.Double', TheNCE.GetDetectorSize(4));
TheNCE.GetAllDetectorData(4, 1, TheNCE.GetDetectorSize(4), data);
[~, rows, cols] = TheNCE.GetDetectorDimensions(4);
% rotates and flips image to reflect ZOS orientation
detectorData = flipud(rot90(reshape(data.double, rows, cols)));

Python

# Get detector data
detectorData = [[0 for x in range(numYPixels)] for x in range(numXPixels)]
for x in range(0,numYPixels,1):
for y in range(0,numXPixels,1):
ret, pixel_val = TheNCE.GetDetectorData(DetObj, pix, 1, 0)
pix += 1
if ret == 1:
detectorData[y][x] = pixel_val
else:
detectorData[x][y] = -1
Parameters
ObjectNumberThe object number of the detector.
DataGetDetectorData
numPixelsThe number of pixels in the data array; this should match the value returned by GetDetectorSize.
detectorDataThe data array to fill with the desired data.
Returns
true for a valid detector; false otherwise

◆ GetAllDetectorDataSafe()

double[,] ZOSAPI.Editors.NCE.INonSeqEditor.GetAllDetectorDataSafe ( int  ObjectNumber,
int  Data 
)

Similar to GetDetectorData, but retrieves data for all pixels at once.

Parameters
ObjectNumberThe object number of the detector.
DataGetDetectorData
Returns
The requested data for a valid detector; null otherwise

◆ GetAllPolarDetectorData()

bool ZOSAPI.Editors.NCE.INonSeqEditor.GetAllPolarDetectorData ( int  ObjectNumber,
PolarDetectorDataType  Data,
uint  numPixels,
[In, Out] double[]  detectorData 
)

Similar to GetDetectorData, but retrieves data for all pixels at once.

Usage (see Example 08 for a full sample)

C#

// To retrieve the entire data array (power, tristim. X/Y/Z, etc. for each pixel)
// can use GetAllPolarDetectorDataSafe(), or GetAllPolarDetectorData().
// Note: GetPolarDetectorData use an enumeration for data type, shown here
ZOSAPI.Editors.NCE.PolarDetectorDataType DataFlag_TriX = ZOSAPI.Editors.NCE.PolarDetectorDataType.TriX;
ZOSAPI.Editors.NCE.PolarDetectorDataType DataFlag_TriY = ZOSAPI.Editors.NCE.PolarDetectorDataType.TriY;
ZOSAPI.Editors.NCE.PolarDetectorDataType DataFlag_TriZ = ZOSAPI.Editors.NCE.PolarDetectorDataType.TriZ;
// now, retrieve the pixel data array
double[,] DetPolarData_TriX = TheSystem.NCE.GetAllPolarDetectorDataSafe(3, DataFlag_TriX);
double[,] DetPolarData_TriY = TheSystem.NCE.GetAllPolarDetectorDataSafe(3, DataFlag_TriY);
double[,] DetPolarData_TriZ = TheSystem.NCE.GetAllPolarDetectorDataSafe(3, DataFlag_TriZ);
Definition: InterfacesNCE.cs:19
PolarDetectorDataType
Definition: InterfacesNCE.cs:262
Definition: InterfacesEditors.cs:12
The ZOSAPI namespace contains classes for initially connecting to zemax. See also ZOSAPI_Connection,...
Definition: IAS_FieldCurvatureAndDistortion.cs:5

C++

// to retrieve the entire data array (power, tristim. X/Y/Z, etc. for each pixel)
// can use GetAllPolarDetectorDataSafe(), or GetAllPolarDetectorData().
// Safe arrays are cumbersome in C++, so use GetAllPolarDetectorData() here.
// initialize output arrays
// detector polar is known to have 181x180 pixels (the defaults); 181*180=32580
double* DetPolarData_TriX = new double[32580];
double* DetPolarData_TriY = new double[32580];
double* DetPolarData_TriZ = new double[32580];
// Note: GetAllPolarDetectorData() uses an enumeration for data type, shown here
PolarDetectorDataType DataFlag_TriX = PolarDetectorDataType::PolarDetectorDataType_TriX;
PolarDetectorDataType DataFlag_TriY = PolarDetectorDataType::PolarDetectorDataType_TriY;
PolarDetectorDataType DataFlag_TriZ = PolarDetectorDataType::PolarDetectorDataType_TriZ;
// now, retrieve the pixel data array
bool SuccessTriX = TheSystem->NCE->GetAllPolarDetectorData(3, DataFlag_TriX, 32580, DetPolarData_TriX);
bool SuccessTriY = TheSystem->NCE->GetAllPolarDetectorData(3, DataFlag_TriY, 32580, DetPolarData_TriY);
bool SuccessTriZ = TheSystem->NCE->GetAllPolarDetectorData(3, DataFlag_TriZ, 32580, DetPolarData_TriZ);

Matlab

% To retrieve the entire data array (power, tristim. X/Y/Z, etc. for each pixel)
% can use GetAllPolarDetectorDataSafe(), or GetAllPolarDetectorData().
% Note: GetPolarDetectorData uses an enumeration for data type, shown here
DataFlag_TriX = ZOSAPI.Editors.NCE.PolarDetectorDataType.TriX;
DataFlag_TriY = ZOSAPI.Editors.NCE.PolarDetectorDataType.TriY;
DataFlag_TriZ = ZOSAPI.Editors.NCE.PolarDetectorDataType.TriZ;
% ".double" converts the .NET type System.Double to a MATLAB double array
DetPolarData_TriX = TheSystem.NCE.GetAllPolarDetectorDataSafe(3, DataFlag_TriX).double; % Tristimulus X value polar pixel
DetPolarData_TriY = TheSystem.NCE.GetAllPolarDetectorDataSafe(3, DataFlag_TriY).double; % Tristimulus Y value on each pixel
DetPolarData_TriZ = TheSystem.NCE.GetAllPolarDetectorDataSafe(3, DataFlag_TriZ).double; % Tristimulus Z value on each pixel

Python

# To retrieve the entire data array (power, tristim. X/Y/Z, etc. for each pixel)
# can use GetAllPolarDetectorDataSafe(), or GetAllPolarDetectorData()
# Note: GetPolarDetectorData uses an enumeration for data type, shown here
DataFlag_TriX = ZOSAPI.Editors.NCE.PolarDetectorDataType.TriX
DataFlag_TriY = ZOSAPI.Editors.NCE.PolarDetectorDataType.TriY
DataFlag_TriZ = ZOSAPI.Editors.NCE.PolarDetectorDataType.TriZ
DetPolarData_TriX = TheSystem.NCE.GetAllPolarDetectorDataSafe(3, DataFlag_TriX) # Tristimulus X value polar pixel
DetPolarData_TriY = TheSystem.NCE.GetAllPolarDetectorDataSafe(3, DataFlag_TriY) # Tristimulus Y value on each pixel
DetPolarData_TriZ = TheSystem.NCE.GetAllPolarDetectorDataSafe(3, DataFlag_TriZ) # Tristimulus Z value on each pixel
Parameters
ObjectNumberThe object number of the detector.
DataGetDetectorData
numPixelsThe number of pixels in the data array; this should match the value returned by GetDetectorSize.
detectorDataThe data array to fill with the desired data.
Returns
true for a valid detector; false otherwise

◆ GetAllPolarDetectorDataSafe()

double[,] ZOSAPI.Editors.NCE.INonSeqEditor.GetAllPolarDetectorDataSafe ( int  ObjectNumber,
PolarDetectorDataType  Data 
)

Similar to GetDetectorData, but retrieves data for all pixels at once.

Usage (see Example 08 for a full sample)

C#

// To retrieve the entire data array (power, tristim. X/Y/Z, etc. for each pixel)
// can use GetAllPolarDetectorDataSafe(), or GetAllPolarDetectorData().
// Note: GetPolarDetectorData use an enumeration for data type, shown here
ZOSAPI.Editors.NCE.PolarDetectorDataType DataFlag_TriX = ZOSAPI.Editors.NCE.PolarDetectorDataType.TriX;
ZOSAPI.Editors.NCE.PolarDetectorDataType DataFlag_TriY = ZOSAPI.Editors.NCE.PolarDetectorDataType.TriY;
ZOSAPI.Editors.NCE.PolarDetectorDataType DataFlag_TriZ = ZOSAPI.Editors.NCE.PolarDetectorDataType.TriZ;
// now, retrieve the pixel data array
double[,] DetPolarData_TriX = TheSystem.NCE.GetAllPolarDetectorDataSafe(3, DataFlag_TriX);
double[,] DetPolarData_TriY = TheSystem.NCE.GetAllPolarDetectorDataSafe(3, DataFlag_TriY);
double[,] DetPolarData_TriZ = TheSystem.NCE.GetAllPolarDetectorDataSafe(3, DataFlag_TriZ);

Matlab

% To retrieve the entire data array (power, tristim. X/Y/Z, etc. for each pixel)
% can use GetAllPolarDetectorDataSafe(), or GetAllPolarDetectorData().
% Note: GetPolarDetectorData uses an enumeration for data type, shown here
DataFlag_TriX = ZOSAPI.Editors.NCE.PolarDetectorDataType.TriX;
DataFlag_TriY = ZOSAPI.Editors.NCE.PolarDetectorDataType.TriY;
DataFlag_TriZ = ZOSAPI.Editors.NCE.PolarDetectorDataType.TriZ;
% ".double" converts the .NET type System.Double to a MATLAB double array
DetPolarData_TriX = TheSystem.NCE.GetAllPolarDetectorDataSafe(3, DataFlag_TriX).double; % Tristimulus X value polar pixel
DetPolarData_TriY = TheSystem.NCE.GetAllPolarDetectorDataSafe(3, DataFlag_TriY).double; % Tristimulus Y value on each pixel
DetPolarData_TriZ = TheSystem.NCE.GetAllPolarDetectorDataSafe(3, DataFlag_TriZ).double; % Tristimulus Z value on each pixel

Python

# To retrieve the entire data array (power, tristim. X/Y/Z, etc. for each pixel)
# can use GetAllPolarDetectorDataSafe(), or GetAllPolarDetectorData()
# Note: GetPolarDetectorData uses an enumeration for data type, shown here
DataFlag_TriX = ZOSAPI.Editors.NCE.PolarDetectorDataType.TriX
DataFlag_TriY = ZOSAPI.Editors.NCE.PolarDetectorDataType.TriY
DataFlag_TriZ = ZOSAPI.Editors.NCE.PolarDetectorDataType.TriZ
DetPolarData_TriX = TheSystem.NCE.GetAllPolarDetectorDataSafe(3, DataFlag_TriX) # Tristimulus X value polar pixel
DetPolarData_TriY = TheSystem.NCE.GetAllPolarDetectorDataSafe(3, DataFlag_TriY) # Tristimulus Y value on each pixel
DetPolarData_TriZ = TheSystem.NCE.GetAllPolarDetectorDataSafe(3, DataFlag_TriZ) # Tristimulus Z value on each pixel
Parameters
ObjectNumberThe object number of the detector.
DataGetDetectorData
Returns
The requested data for a valid detector; null otherwise

◆ GetClosestGlass()

string ZOSAPI.Editors.NCE.INonSeqEditor.GetClosestGlass ( int  ObjectNumber)

Get the closest catalog glass to the model glass on the specified object. Note that this should only be called for an object that uses a model glass solve, otherwise the result is undefined.

Parameters
ObjectNumberDesired object (1 to NumberOfObjects)
Returns
The glass name if found, otherwise an empty string

◆ GetCoherentData()

bool ZOSAPI.Editors.NCE.INonSeqEditor.GetCoherentData ( int  ObjectNumber,
int  pixel,
DetectorDataType  Data,
out double  Value 
)

Gets data from a NSC detector.

Usage (see Example 08 for a full sample)

C#

// Read in the detector rectangle coherent data
// GetCoherentData() is very similar to the operand NSDC
// Can retrieve real, imaginary, amplitude, power, with 'data' input
// for pix = 0, get sum on detector; pix > 0 gives single pixel data
TheSystem.NCE.GetCoherentData(4, 0, ZOSAPI.Editors.NCE.DetectorDataType.Amplitude, out double DetRectangle_CoherentAmp); // obj=4, pix=0, data=2
TheSystem.NCE.GetCoherentData(4, 0, ZOSAPI.Editors.NCE.DetectorDataType.Power, out double DetRectangle_CoherentPower); // obj=4, pix=0, data=3

C++

// Read in the detector rectangle coherent data
// GetCoherentData() is very similar to the operand NSDC
// Can retrieve real, imaginary, amplitude, power, with 'data' input
// for pix = 0, get sum on detector; pix > 0 gives single pixel data
double TotalAmp, TotalPower;
bool SuccessAmp = TheSystem->NCE->GetCoherentData(4, 0, DetectorDataType::DetectorDataType_Amplitude, &TotalAmp); // obj=4, pix=0, data=2
bool SuccessPower = TheSystem->NCE->GetCoherentData(4, 0, DetectorDataType::DetectorDataType_Power, &TotalPower); // obj=4, pix=0, data=3

Matlab

% Read in the detector rectangle coherent data
% GetCoherentData() is very similar to the operand NSDC
% can retrieve real, imaginary, amplitude, power, with 'data' input
% for pix=0, get sum on detector; pix>0 gives single pixel data
[success, DetRectangle_CoherentAmp] = TheSystem.NCE.GetCoherentData(4, 0, ZOSAPI.Editors.NCE.DetectorDataType.Amplitude); % obj=4, pix=0, data=2
[success, DetRectangle_CoherentPower] = TheSystem.NCE.GetCoherentData(4, 0, ZOSAPI.Editors.NCE.DetectorDataType.Power); % obj=4, pix=0, data=3
DetectorDataType
Definition: InterfacesNCE.cs:252

Python

# Read in the detector rectangle coherent data
# GetCoherentData() is very similar to the operand NSDC
# can retrieve real, imaginary, amplitude, power with 'data' input
# for pix=0, get sum on detector; pix>0 gives single pixel data
success, DetRectangle_CoherentAmp = TheSystem.NCE.GetCoherentData(4, 0, ZOSAPI.Editors.NCE.DetectorDataType.Amplitude, 0) # obj=4, pix=0, data=2
success, DetRectangle_CoherentPower = TheSystem.NCE.GetCoherentData(4, 0, ZOSAPI.Editors.NCE.DetectorDataType.Power, 0) # obj=4, pix=0, data=3
Parameters
ObjectNumberThe object number of the detector.
pixelThe pixel number on the detector (1-based); use 0 to retrieve the sum over all pixels.
DataThe desired data type.
ValueThe value.
Returns
True for a valid detector; false otherwise

◆ GetColorDetectorData()

bool ZOSAPI.Editors.NCE.INonSeqEditor.GetColorDetectorData ( int  ObjectNumber,
int  pixel,
bool  angleSpace,
int  Data,
int  numIgnoredPixels,
double  Wavelength,
out double  Value 
)

Gets data from a NSC Detector Color.

Parameters
ObjectNumberThe object number of the detector.


= 0: clear all detectors

> 0: retrieve data from the detector

< 0: clear the detector.

Parameters
pixelThe pixel number on the detector (1-based).

>0: Retrieve data for the specified pixel.

0: Sum of all data for all pixels on the detector. For chromaticity coordinates this is the average over all pixels in the detector that have non-zero lumen values.
The area values described below are the area of the entire detector, measured in analysis units for position space data or solid angle in steradians for angle space data.

-1: Maximum data.

-2: Minimum data.

-3: Number of rays striking the detector.

Parameters
angleSpacetrue for angle space data, otherwise position space data.
DataThe desired data type.

1: power in 'sprefix' watts where 'sprefix' is the source units prefix.

2: power/area in 'aprefix' watts per 'area' where 'aprefix' is the analysis units prefix.
If angleSpace is false 'area' is the area in analysis units; otherwise, 'area' is solid angle in steradians.

3: power in 'sprefix' lumens where 'sprefix' is the source units prefix.

4: power/area in 'aprefix' lumens per 'area' where 'aprefix' is the analysis units prefix.
If angleSpace is false 'area' is the area in analysis units; otherwise, 'area' is solid angle in steradians.

5/6: CIE 1931 chromaticity coordinate x/y.

7/8: CIE 1976 chromaticity coordinate u'/v'.

9/10/11: CIE 1931 tristiulus X/Y/Z values in lumens per 'area'. If angleSpace is false 'area' is the area in analysis units; otherwise, 'area' is solid angle in steradians.

12/13: Color Rendering Index (CRI) and Correlated Color Temperature (CCT), the latter value in Kelvin. These values are only returned if the option to “Record Spectral Data” has been selected for the Detector Color object (only available in OpticStudio-Premium) and if the pixel is 0 and angleSpace is false. The returned values are based on the variation of flux with wavelength over the entire detector.

17/18/19/20/21: The Centroid X, Y and RMS radius, X, Y in specified Spectral Bin. See description of Wavelength for specifying the Spectral Bin. See Detector Settings in Type section of the Object Properties for defining Spectral Range of Bins.

Parameters
numIgnoredPixelsIf Pix# is not a positive integer, then a number of edge pixels may be ignored in the calculation if desired.

The number of edge pixels that will be ignored is given by the # Ignored input. For non- zero values of # Ignored, the number of pixels accounted for in the calculation will be reduced along all boundaries of the detector. For example, if a detector has 100 pixels in X and 200 pixels in Y and the numIgnoredPixels value is 2, then the calculation will be based upon detector data from 96 pixels in X and 196 pixels in Y, with data from the last 2 edge pixels along the left, right, bottom and top boundaries all ignored. Calculations that are not affected by the numIgnoredPixels input are the number of rays striking the detector, as given by pixel = -3, and the CRI and CCT values, as given by Data = 12 and Data = 13, respectively (the numIgnoredPixels input also does not affect any values calculated for positive integer inputs to pixel ).

If the source units are joules, then the data 1 and 2 are in joules and data 3 and 4 are in talbots.See “Units”. See also NSDD and NSDP.

Parameters
WavelengthSpecifies which spectral bin's data is calculated for centroid X/Y and RMS radius/X/Y. If the value of Wavelength is inside one bin's spectral range, the bin's data will be selected for calculation. See "Record Spectral Data" for details of spectral binning.
ValueThe return value.
Returns
True for a valid detector; False otherwise

◆ GetDetectorData()

bool ZOSAPI.Editors.NCE.INonSeqEditor.GetDetectorData ( int  ObjectNumber,
int  pixel,
int  Data,
out double  Value 
)

Gets data from a NSC detector.

Usage (see Example 10 for a full sample)

C#

// Retrieve detector data and detector information
INonSeqEditor TheNCE = TheSystem.NCE;
Double total_hits, total_flux;
Boolean hits_bool_return, flux_bool_return, dims_bool_return;
UInt32 X_detectorDims, Y_detectorDims;
hits_bool_return = TheNCE.GetDetectorData(4, -3, 0, out total_hits); // Object Number=4, Pix -3 & Data=0 (total hits)
flux_bool_return = TheNCE.GetDetectorData(4, 0, 0, out total_flux); // Object Number=4, Pix=0 & Data=0 (total flux)
dims_bool_return = TheNCE.GetDetectorDimensions(4, out X_detectorDims, out Y_detectorDims); // get number of pixels in X, Y
Console.WriteLine("total hits = " + total_hits + "\n" + "total flux = " + total_flux);
UInt32 length = X_detectorDims * Y_detectorDims;
Double[] pix = new Double[length]; // Create array to store flux data for each pixel
Boolean pix_bool;
// mrh: should this be 0 or 1 index, the first Pix# is 1
for (int i = 0; i < length; i++) // loop through pixels, store value in pix
{
pix_bool = TheNCE.GetDetectorData(4, i, 0, out pix[i]);
}
bool GetDetectorDimensions(int ObjectNumber, out uint Rows, out uint Cols)
Gets the dimensions of the specified detector.
bool GetDetectorData(int ObjectNumber, int pixel, int Data, out double Value)
Gets data from a NSC detector.

C++

// Retrieve detector data and detector information
INonSeqEditorPtr TheNCE = TheSystem->NCE;
double total_hits, total_flux;
bool hits_bool_return, flux_bool_return, dims_bool_return;
unsigned long X_detectorDims, Y_detectorDims;
hits_bool_return = TheNCE->GetDetectorData(4, -3, 0, &total_hits); // Object Number=4, Pix -3 & Data=0 (total hits)
flux_bool_return = TheNCE->GetDetectorData(4, 0, 0, &total_flux); // Object Number=4, Pix=0 & Data=0 (total flux)
dims_bool_return = TheNCE->GetDetectorDimensions(4, &X_detectorDims, &Y_detectorDims); // get number of pixels in X, Y
cout << "total hits = " << total_hits << "\n" << "total flux = " << total_flux << endl;
int length = X_detectorDims * Y_detectorDims;
double *pix = new double[length]; // Create array to store flux data for each pixel
bool pix_bool;
for (int i = 0; i < length; i++) // loop through pixels, store value in pix
{
pix_bool = TheNCE->GetDetectorData(4, i, 0, &pix[i]);
}

Matlab

% Retrieve detector data and detector information
TheNCE = TheSystem.NCE;
[hits_bool_return, total_hits] = TheNCE.GetDetectorData(4, -3, 0); % Object Number=4, Pix -3 & Data=0 (total hits)
[flux_bool_return, total_flux] = TheNCE.GetDetectorData(4, 0, 0); % Object Number=4, Pix=0 & Data=0 (total flux)
[dims_bool_return, X_detectorDims, Y_detectorDims] = TheNCE.GetDetectorDimensions(4); % get number of pixels in X, Y
fprintf('total hits = %i\ntotal flux = %10.8f\n', total_hits, total_flux);
length = X_detectorDims * Y_detectorDims + 1;
pix = zeros(length);
for i = 1:length
[pix_bool, pix(i)] = TheNCE.GetDetectorData(4, int32(i), 0);
end

Python

# Retrieve detector data and detector information
TheNCE = TheSystem.NCE
hits_bool_return, total_hits = TheNCE.GetDetectorData(4, -3, 0, 0) # Object Number=4, Pix -3 & Data=0 (total hits)
flux_bool_return, total_flux = TheNCE.GetDetectorData(4, 0, 0, 0) # Object Number=4, Pix=0 & Data=0 (total flux)
print(" total hits = ",total_hits, "\n", "total flux = ",total_flux)
dims_bool_return, X_detectorDims, Y_detectorDims = TheNCE.GetDetectorDimensions(4, 0, 0) # get number of pixels in X, Y
pix = [] # Create array to store flux data for each pixel
length = pix.__len__()
while pix.__len__() < X_detectorDims*Y_detectorDims: # loop through pixels, store value in pix
length += 1
pix_bool, value = TheNCE.GetDetectorData(4, length, 0, 0)
pix.append(value)
Parameters
ObjectNumberThe object number of the detector.

= 0: clear all detectors

> 0: retrieve data from the detector

< 0: clear the detector.

Parameters
pixelThe pixel number on the detector (1-based).

For Detector Rectangles, Detector Surfaces, and all faceted detectors

0: Sum of the total flux in position space, average flux/area in position space, or total flux in angle space for all pixels for that detector object, for Data = 0, 1, or 2, respectively.

-1: Maximum flux or flux/area.

-2: Minimum flux or flux/area.

-3: Number of rays striking the detector.

-4: Standard deviation (RMS from the mean) of all the non-zero pixel data.

-5: The mean value of all the non-zero pixel data.

-6, -7, -8: The x, y, or z coordinate of the position or angle Irradiance or Intensity centroid, respectively.

-9,-10, -11, -12, -13: The RMS radius, x, y, z, or xy cross term distance or angle of all the pixel data with respect to the centroid. These are the second moments r^2, x^2, y^2, z^2, and xy, respectively


For Detector Volumes

Pix# is interpreted as the voxel number

Parameters
DataThe desired data type.

For Detector Rectangles, Detector Surfaces, and all faceted detectors

0: flux

1: flux/area

2: flux/solid angle pixel

Note - only values 0 and 1 (for flux and flux/area) are supported for faceted detectors.


For faceted detectors

4: absorbed flux

5: absorbed flux/area


For Detector Volumes

0: incident flux

1: absorbed flux

2: absorbed flux/unit volume

Parameters
ValueThe return value.
Returns
True for a valid detector; False otherwise
Examples
CSharpStandalone_02_NSC_ray_trace.cs, and CSharpStandalone_10_NSC_ZRD_filter_string.cs.

◆ GetDetectorDimensions()

bool ZOSAPI.Editors.NCE.INonSeqEditor.GetDetectorDimensions ( int  ObjectNumber,
out uint  Rows,
out uint  Cols 
)

Gets the dimensions of the specified detector.

Usage (see Example 10 for a full sample)

C#

// Retrieve detector data and detector information
INonSeqEditor TheNCE = TheSystem.NCE;
Double total_hits, total_flux;
Boolean hits_bool_return, flux_bool_return, dims_bool_return;
UInt32 X_detectorDims, Y_detectorDims;
hits_bool_return = TheNCE.GetDetectorData(4, -3, 0, out total_hits); // Object Number=4, Pix -3 & Data=0 (total hits)
flux_bool_return = TheNCE.GetDetectorData(4, 0, 0, out total_flux); // Object Number=4, Pix=0 & Data=0 (total flux)
dims_bool_return = TheNCE.GetDetectorDimensions(4, out X_detectorDims, out Y_detectorDims); // get number of pixels in X, Y
Console.WriteLine("total hits = " + total_hits + "\n" + "total flux = " + total_flux);
UInt32 length = X_detectorDims * Y_detectorDims;
Double[] pix = new Double[length]; // Create array to store flux data for each pixel
Boolean pix_bool;
// mrh: should this be 0 or 1 index, the first Pix# is 1
for (int i = 0; i < length; i++) // loop through pixels, store value in pix
{
pix_bool = TheNCE.GetDetectorData(4, i, 0, out pix[i]);
}

C++

// Retrieve detector data and detector information
INonSeqEditorPtr TheNCE = TheSystem->NCE;
double total_hits, total_flux;
bool hits_bool_return, flux_bool_return, dims_bool_return;
unsigned long X_detectorDims, Y_detectorDims;
hits_bool_return = TheNCE->GetDetectorData(4, -3, 0, &total_hits); // Object Number=4, Pix -3 & Data=0 (total hits)
flux_bool_return = TheNCE->GetDetectorData(4, 0, 0, &total_flux); // Object Number=4, Pix=0 & Data=0 (total flux)
dims_bool_return = TheNCE->GetDetectorDimensions(4, &X_detectorDims, &Y_detectorDims); // get number of pixels in X, Y
cout << "total hits = " << total_hits << "\n" << "total flux = " << total_flux << endl;
int length = X_detectorDims * Y_detectorDims;
double *pix = new double[length]; // Create array to store flux data for each pixel
bool pix_bool;
for (int i = 0; i < length; i++) // loop through pixels, store value in pix
{
pix_bool = TheNCE->GetDetectorData(4, i, 0, &pix[i]);
}

Matlab

% Retrieve detector data and detector information
TheNCE = TheSystem.NCE;
[hits_bool_return, total_hits] = TheNCE.GetDetectorData(4, -3, 0); % Object Number=4, Pix -3 & Data=0 (total hits)
[flux_bool_return, total_flux] = TheNCE.GetDetectorData(4, 0, 0); % Object Number=4, Pix=0 & Data=0 (total flux)
[dims_bool_return, X_detectorDims, Y_detectorDims] = TheNCE.GetDetectorDimensions(4); % get number of pixels in X, Y
fprintf('total hits = %i\ntotal flux = %10.8f\n', total_hits, total_flux);
length = X_detectorDims * Y_detectorDims + 1;
pix = zeros(length);
for i = 1:length
[pix_bool, pix(i)] = TheNCE.GetDetectorData(4, int32(i), 0);
end

Python

# Retrieve detector data and detector information
TheNCE = TheSystem.NCE
hits_bool_return, total_hits = TheNCE.GetDetectorData(4, -3, 0, 0) # Object Number=4, Pix -3 & Data=0 (total hits)
flux_bool_return, total_flux = TheNCE.GetDetectorData(4, 0, 0, 0) # Object Number=4, Pix=0 & Data=0 (total flux)
print(" total hits = ",total_hits, "\n", "total flux = ",total_flux)
dims_bool_return, X_detectorDims, Y_detectorDims = TheNCE.GetDetectorDimensions(4, 0, 0) # get number of pixels in X, Y
pix = [] # Create array to store flux data for each pixel
length = pix.__len__()
while pix.__len__() < X_detectorDims*Y_detectorDims: # loop through pixels, store value in pix
length += 1
pix_bool, value = TheNCE.GetDetectorData(4, length, 0, 0)
pix.append(value)
Parameters
ObjectNumberThe object number of the detector.
RowsThe # of rows in the detector.
ColsThe # of columns if the detector or rectangular; 1 for other detector types; 0 for invalid inputs.
Returns
true for a valid detctor number; false otherwise.
Examples
CSharpStandalone_10_NSC_ZRD_filter_string.cs.

◆ GetDetectorSize()

uint ZOSAPI.Editors.NCE.INonSeqEditor.GetDetectorSize ( int  ObjectNumber)

Gets the total number of pixels for the specified detector.

Parameters
ObjectNumberThe object number of the detector.
Returns
The number of pixels in the detector (rows * columns).

◆ GetGlass()

bool ZOSAPI.Editors.NCE.INonSeqEditor.GetGlass ( int  ObjectNumber,
out string  glassName,
out double  nd,
out double  vd,
out double  dpgf 
)

Retrieve data about the glass on any object.

Parameters
ObjectNumberObject # (1-based)
glassNameThe name of the glass
ndThe nd value
vdThe vd value
dpgfThe dpgf value
Returns
false if the object is not valid, is not made of glass, or is a gradient index; otherwise, true.

◆ GetId()

long ZOSAPI.Editors.NCE.INonSeqEditor.GetId ( int  objectNumber)

◆ GetIndex()

int ZOSAPI.Editors.NCE.INonSeqEditor.GetIndex ( int  ObjectNumber,
int  NumberOfWavelengths,
[In, Out] double[]  indexAtWavelength 
)

Extract refraction data for any object.

Parameters
ObjectNumberObject # (1-based)
NumberOfWavelengthsThe number of wavelenghts to retrieve. Note: this number must be the length of indexAtWavelength.
indexAtWavelengthWhen the function returns, this will hold the index at each system wavelength. Note: only data for the minimum of 'NumberOfWavelengths' and the number of system wavelengths will be populated.
Returns
The count of index data successfully read.

◆ GetMatrix()

bool ZOSAPI.Editors.NCE.INonSeqEditor.GetMatrix ( int  ObjectNumber,
out double  R11,
out double  R12,
out double  R13,
out double  R21,
out double  R22,
out double  R23,
out double  R31,
out double  R32,
out double  R33,
out double  Xo,
out double  Yo,
out double  Zo 
)

Get the rotation and position matrices for NSC objects relative to the NSC surface origin.

Usage (see Example 08 for a full sample)

C#

// Co-locate object 3 with object 2 (here, could alternatively use Ref Object flag)
bool success = TheSystem.NCE.GetMatrix(2, out double R11, out double R12, out double R13, out double R21,
out double R22, out double R23, out double R31, out double R32, out double R33, out double Xo,
out double Yo, out double Zo);
obj3.XPosition = Xo;
obj3.YPosition = Yo;
obj3.ZPosition = Zo;
// Conversion from rotation matrix to tilts described in KBA "Rotation matrix and Tilt About X/Y/Z in OpticStudio"
obj3.TiltAboutX = (180 / Math.PI) * Math.Atan2(-1 * R23, R33);
obj3.TiltAboutY = (180 / Math.PI) * Math.Asin(R13);
obj3.TiltAboutZ = (180 / Math.PI) * Math.Atan2(-1 * R12, R11);

C++

// Co-locate object 3 with object 2 (here, could alternatively use the 'Ref Object' flag)
double R11, R12, R13, R21, R22, R23, R31, R32, R33, Xo, Yo, Zo;
bool MatrixSuccess = TheSystem->NCE->GetMatrix(2, &R11, &R12, &R13, &R21, &R22, &R23, &R31, &R32, &R33, &Xo, &Yo, &Zo);
obj3->XPosition = Xo;
obj3->YPosition = Yo;
obj3->ZPosition = Zo;
// Conversion from rotation matrix to tilts described in KBA "Rotation matrix and Tilt About X/Y/Z in OpticStudio"
obj3->TiltAboutX = atan2(-1 * R23, R33);
obj3->TiltAboutY = asin(R13);
obj3->TiltAboutZ = atan2(-1 * R12, R11);

Matlab

% Co-locate object 3 with object 2 (here, could alternatively use Ref Object flag)
[success, R11, R12, R13, R21, R22, R23, R31, R32, R33, Xo, Yo, Zo]= TheSystem.NCE.GetMatrix(2);
obj3.XPosition = Xo;
obj3.YPosition = Yo;
obj3.ZPosition = Zo;
% Conversion from rotation matrix to tilts described in KBA "Rotation Matrix and Tilt About X/Y/Z in OpticStudio"
obj3.TiltAboutX = rad2deg(atan2(-1*R23,R33));
obj3.TiltAboutY = rad2deg(asin(R13));
obj3.TiltAboutZ = rad2deg(atan2(-1*R12, R11));
@ NCE
Non-sequential Component Editor.

Python

# Co-locate object 3 with object 2 (here, could alternatively use Ref Object flag)
# need to use placeholders for out parameters
success, R11, R12, R13, R21, R22, R23, R31, R32, R33, Xo, Yo, Zo = TheSystem.NCE.GetMatrix(2, 11, 12, 13, 21, 22, 23, 31, 32, 33, 1, 2, 3)
obj3.XPosition = Xo
obj3.YPosition = Yo
obj3.ZPosition = Zo
# Conversion from rotation matrix to tilts described in KBA "Rotation Matrix and Tilt About X/Y/Z in OpticStudio"
obj3.TiltAboutX = math.degrees(math.atan2(-1 * R23, R33))
obj3.TiltAboutY = math.degrees(math.asin(R13))
obj3.TiltAboutZ = math.degrees(math.atan2(-1 * R12, R11))
Parameters
ObjectNumberObject # (1-based)
R11Row 1, Column 1
R12Row 1, Column 2
R13Row 1, Column 3
R21Row 2, Column 1
R22Row 2, Column 2
R23Row 2, Column 3
R31Row 3, Column 1
R32Row 3, Column 2
R33Row 3, Column 3
XoX offset
YoY offset
ZoZ offset
Returns
True for a valid object; False otherwise

◆ GetObjectAt()

INCERow ZOSAPI.Editors.NCE.INonSeqEditor.GetObjectAt ( int  ObjectNumber)

Gets the object at the specified position.

Usage (see Example 17 for a full sample)

C#

//Non-sequential component editor
INonSeqEditor TheNCE = TheSystem.NCE;
TheNCE = TheSystem.NCE;
INCERow Object_1 = TheNCE.InsertNewObjectAt(1);
INCERow Object_2 = TheNCE.InsertNewObjectAt(2);
INCERow Object_3 = TheNCE.GetObjectAt(3);
All data for a Non-Sequential Component Editor object. This interface can be accessed via the INonSeq...
Definition: InterfacesNCE.cs:1198
INCERow GetObjectAt(int ObjectNumber)
Gets the object at the specified position.
INCERow InsertNewObjectAt(int ObjectNumber)
Inserts a new object at the specified position.

C++

//Non-sequential component editor
INonSeqEditorPtr TheNCE = TheSystem->NCE;
TheNCE = TheSystem->NCE;
INCERowPtr Object_1 = TheNCE->InsertNewObjectAt(1);
INCERowPtr Object_2 = TheNCE->InsertNewObjectAt(2);
INCERowPtr Object_3 = TheNCE->GetObjectAt(3);

Matlab

% Non-sequential component editor
TheNCE = TheSystem.NCE;
Object_1 = TheNCE.InsertNewObjectAt(1);
Object_2 = TheNCE.InsertNewObjectAt(2);
Object_3 = TheNCE.GetObjectAt(3);

Python

# Non-sequential component editor
TheNCE = TheSystem.NCE
Object_1 = TheNCE.InsertNewObjectAt(1)
Object_2 = TheNCE.InsertNewObjectAt(2)
Object_3 = TheNCE.GetObjectAt(3)
Parameters
ObjectNumberThe object number (1 to NumberOfObjects).
Returns
Examples
CSharpStandalone_06_nsc_phase.cs, CSharpStandalone_09_NSC_CAD.cs, CSharpStandalone_17_NSC_BulkScatter.cs, CSharpStandalone_21_White_LED_Phosphor.cs, CSharpStandalone_24_nsc_detectors.cs, and CSharpStandalone_25_source_spectrum_diffraction_grating.cs.

◆ GetPolarDetectorData()

bool ZOSAPI.Editors.NCE.INonSeqEditor.GetPolarDetectorData ( int  ObjectNumber,
int  pixel,
PolarDetectorDataType  Data,
out double  Value 
)

Gets data from a NSC detector.

Usage (see Example 08 for a full sample)

C++

// Here we read in the detector polar data from ZOS
// GetPolarDetectorData() is very similar to the MF operand NSDP;
// can retrieve RMS (degrees), total power, chromatricity, etc. (see NSDP in OpticStudio help)
// Note: GetPolarDetectorData() uses an enumeration for data type, shown here
double DetPolarData_RadialRMS, DetPolarData_ChromX, DetPolarData_ChromY;
PolarDetectorDataType DataFlag_Power = PolarDetectorDataType::PolarDetectorDataType_Power;
PolarDetectorDataType DataFlag_ChromX = PolarDetectorDataType::PolarDetectorDataType_Cx;
PolarDetectorDataType DataFlag_ChromY = PolarDetectorDataType::PolarDetectorDataType_Cy;
bool successRadialRMS = TheSystem->NCE->GetPolarDetectorData(3, -4, DataFlag_Power, &DetPolarData_RadialRMS);
bool successChromX = TheSystem->NCE->GetPolarDetectorData(3, 0, DataFlag_ChromX, &DetPolarData_ChromX);
bool successChromY = TheSystem->NCE->GetPolarDetectorData(3, 0, DataFlag_ChromY, &DetPolarData_ChromY);
Parameters
ObjectNumberThe object number of the detector.

= 0: clear all detectors

> 0: retrieve data from the detector

< 0: clear the detector.

Parameters
pixelThe pixel number on the detector (1-based).

For Detector Rectangles, Detector Surfaces, and all faceted detectors

0: Sum of the total flux in position space, average flux/area in position space, or total flux in angle space for all pixels for that detector object, for Data = 0, 1, or 2, respectively.

-1: Maximum flux or flux/area.

-2: Minimum flux or flux/area.

-3: Number of rays striking the detector.

-4: Standard deviation (RMS from the mean) of all the non-zero pixel data.

-5: The mean value of all the non-zero pixel data.

-6, -7, -8: The x, y, or z coordinate of the position or angle Irradiance or Intensity centroid, respectively.

-9,-10, -11, -12, -13: The RMS radius, x, y, z, or xy cross term distance or angle of all the pixel data with respect to the centroid. These are the second moments r^2, x^2, y^2, z^2, and xy, respectively


For Detector Volumes

Pix# is interpreted as the voxel number

Parameters
DataThe desired data type.

For Detector Rectangles, Detector Surfaces, and all faceted detectors

0: flux

1: flux/area

2: flux/solid angle pixel

Note - only values 0 and 1 (for flux and flux/area) are supported for faceted detectors.


For Detector Volumes

0: incident flux

1: absorbed flux

2: absorbed flux/unit volume

Parameters
ValueThe return value.
Returns
True for a valid detector; False otherwise

◆ HideNCE()

void ZOSAPI.Editors.NCE.INonSeqEditor.HideNCE ( )

Closes this editor in the UI. Note that this only has an effect if the IOpticalSystem.Mode is ZOSAPI_Mode.Plugin.

Returns

◆ InsertNewObjectAt()

INCERow ZOSAPI.Editors.NCE.INonSeqEditor.InsertNewObjectAt ( int  ObjectNumber)

Inserts a new object at the specified position.

Usage (see Example 17 for a full sample)

C#

//Non-sequential component editor
INonSeqEditor TheNCE = TheSystem.NCE;
TheNCE = TheSystem.NCE;
INCERow Object_1 = TheNCE.InsertNewObjectAt(1);
INCERow Object_2 = TheNCE.InsertNewObjectAt(2);
INCERow Object_3 = TheNCE.GetObjectAt(3);

C++

//Non-sequential component editor
INonSeqEditorPtr TheNCE = TheSystem->NCE;
TheNCE = TheSystem->NCE;
INCERowPtr Object_1 = TheNCE->InsertNewObjectAt(1);
INCERowPtr Object_2 = TheNCE->InsertNewObjectAt(2);
INCERowPtr Object_3 = TheNCE->GetObjectAt(3);

Matlab

% Non-sequential component editor
TheNCE = TheSystem.NCE;
Object_1 = TheNCE.InsertNewObjectAt(1);
Object_2 = TheNCE.InsertNewObjectAt(2);
Object_3 = TheNCE.GetObjectAt(3);

Python

# Non-sequential component editor
TheNCE = TheSystem.NCE
Object_1 = TheNCE.InsertNewObjectAt(1)
Object_2 = TheNCE.InsertNewObjectAt(2)
Object_3 = TheNCE.GetObjectAt(3)
Parameters
ObjectNumberThe object number (1 to NumberOfObjects+1).
Returns
Examples
CSharpStandalone_06_nsc_phase.cs, CSharpStandalone_09_NSC_CAD.cs, CSharpStandalone_17_NSC_BulkScatter.cs, CSharpStandalone_24_nsc_detectors.cs, and CSharpStandalone_25_source_spectrum_diffraction_grating.cs.

◆ LoadDetector()

bool ZOSAPI.Editors.NCE.INonSeqEditor.LoadDetector ( int  ObjectNumber,
string  fileName,
bool  appendData 
)

Loads the data saved in a file to an NSC Detector Rectangle, Detector Color, Detector Polar, or Detector Volume object.

Usage (see Example 08 for a full sample)

C#

// Load detector data -- for analyzing previous ray trace results
// For detector polar, the file type is .DDP; for detector rectangle, it's .DDR
TheSystem.NCE.LoadDetector(3, TheApplication.ZemaxDataDir + "\\Samples\\API\\CS\\detector3polar.DDP", false);
TheSystem.NCE.LoadDetector(4, TheApplication.ZemaxDataDir + "\\Samples\\API\\CS\\detector4rect.DDR", false);

C++

// Load detector data -- for analyzing previous ray trace results
// For detector polar, the file type is .DDP; for detector rectangle, it's .DDR
TheSystem->NCE->LoadDetector(3, TheApplication->ZemaxDataDir + "\\Samples\\API\\CPP\\detector3polar.DDP", false);
TheSystem->NCE->LoadDetector(4, TheApplication->ZemaxDataDir + "\\Samples\\API\\CPP\\detector4rect.DDR", false);

Matlab

% Load detector data -- for analyzing previous ray trace results
% For detector polar, the file type is .DDP; for detector rectangle, it's .DDR
DetectorPolarFile = System.String.Concat(TheApplication.ZemaxDataDir, '\Samples\API\MATLAB\detector3polar.DDP');
DetectorRectFile = System.String.Concat(TheApplication.ZemaxDataDir, '\Samples\API\MATLAB\detector4rect.DDR');
TheSystem.NCE.LoadDetector(3, DetectorPolarFile, false);
TheSystem.NCE.LoadDetector(4, DetectorRectFile, false);

Python

# Load detector data -- for analyzing previous ray trace results
# For detector polar, the file type is .DDP; for detector rectangle, it's .DDR
DetectorPolarFile = TheApplication.ZemaxDataDir + "\\Samples\\API\\Python\\detector3polar.DDP"
DetectorRectFile = TheApplication.ZemaxDataDir + "\\Samples\\API\\Python\\detector4rect.DDR"
TheSystem.NCE.LoadDetector(3, DetectorPolarFile, False)
TheSystem.NCE.LoadDetector(4, DetectorRectFile, False)
Parameters
ObjectNumberThe object number of the detector.
fileNameName of the file to load.

fileName may include the full path, if no path is provided the path of the current lens file is used.

The extension should be DDR, DDC, DDP, or DDV for Detector Rectangle, Color, Polar, and Volume objects, respectively.

Parameters
appendDataIf set to true then the data from the file are summed to the existing detector data, else the detector is cleared first.

When appendData is true, data from the file must have identical detector properties as the existing detector; otherwise the sum cannot be performed.

Returns
true if the operation succeeded; false otherwise.

◆ ModifyReferenceObjects()

IMessage ZOSAPI.Editors.NCE.INonSeqEditor.ModifyReferenceObjects ( int  first,
int  last,
int  reference 
)

ModifyReferenceObjects modifies objects numbered first through last according to reference by

  • updating each selected object's reference object and
  • updating the position and rotation angle for each object to retain its current position and orientation.
Parameters
firstThe number (1-based) of the first object to modify.
lastThe number (1-based) of the last object to modify.
referenceEither
  • 0, for referencing the vertex of the Non-sequential Component Editor surface (i.e., "Global Coordinates"), or
  • a 1-based surface number.
In either case, reference must be less than min(first , last ).
Returns
Null on success; non-null if an error occurred.

◆ NextNSCGroup()

bool ZOSAPI.Editors.NCE.INonSeqEditor.NextNSCGroup ( )

Selects the next available non-sequential surface.

Returns

◆ ObjectNameFromObjectType()

string ZOSAPI.Editors.NCE.INonSeqEditor.ObjectNameFromObjectType ( ObjectType  objectType)

◆ ObjectTypeFromObjectName()

ObjectType ZOSAPI.Editors.NCE.INonSeqEditor.ObjectTypeFromObjectName ( string  objectName)

◆ PrevNSCGroup()

bool ZOSAPI.Editors.NCE.INonSeqEditor.PrevNSCGroup ( )

Selects the previous available non-sequential surface.

Returns

◆ ReloadAllObjects()

void ZOSAPI.Editors.NCE.INonSeqEditor.ReloadAllObjects ( )

Reloads all objects in the editor (for more information, see the OpticStudio manual).

◆ ReloadObject()

void ZOSAPI.Editors.NCE.INonSeqEditor.ReloadObject ( int  ObjectNumber)

Reloads the specified object (for more information, see the OpticStudio manual).

Parameters
ObjectNumberThe object number to reload (1 to NumberOfObjects).

◆ RemoveObjectAt()

bool ZOSAPI.Editors.NCE.INonSeqEditor.RemoveObjectAt ( int  ObjectNumber)

Removes the object at the specified location.

Usage (see Example 08 for a full sample)

C#

// delete unnecessary object from NSCE
TheSystem.NCE.RemoveObjectAt(3);
// Add detector polar, change radial size to 20mm
ZOSAPI.Editors.NCE.INCERow obj3 = TheSystem.NCE.InsertNewObjectAt(3);
obj3.ChangeType(DetectorPolar);
// Set the detector polar radial size to 20
obj3.GetCellAt(12).DoubleValue = 20; // cell 12 always corresponds to 'Par2' in the NSCE
double DoubleValue
Gets or sets the double precision value of this cell. Note that if DataType is not CellDataType....
Definition: InterfacesEditors.cs:340
IEditorCell GetCellAt(int pos)
Gets the cell at the specified index (IEditor.MinColumn to IEditor.MaxColumn).
bool ChangeType(IObjectTypeSettings settings)
Changes the current object to the specified type. Use GetObjectTypeSettings to get the relevant setti...
IObjectTypeSettings GetObjectTypeSettings(ObjectType type)
Create the settings for the specified type. Use this method to specify any extra data required to cha...
This interface is used for selecting any files required by a object, and for changing object types....
Definition: InterfacesNCE.cs:1110

C++

// Delete unnecessary object from NSCE
bool success = TheSystem->NCE->RemoveObjectAt(3);
// Add detector polar, change radial size to 20mm
INCERowPtr obj3 = TheSystem->NCE->InsertNewObjectAt(3);
IObjectTypeSettingsPtr DetectorPolar = obj3->GetObjectTypeSettings(ObjectType::ObjectType_DetectorPolar);
obj3->ChangeType(DetectorPolar);
// Set the detector polar radial size to 20
((IEditorRowPtr)obj3)->GetCellAt(12)->DoubleValue = 20; // cell 12 always corresponds to 'Par2' in the NSCE

Matlab

% delete unnecessary object from NSCE
TheSystem.NCE.RemoveObjectAt(3);
% Add detector polar, change radial size to 20mm
obj3 = TheSystem.NCE.InsertNewObjectAt(3);
DetectorPolar = obj3.GetObjectTypeSettings(ZOSAPI.Editors.NCE.ObjectType.DetectorPolar);
obj3.ChangeType(DetectorPolar);
% Set the detector polar radial size to 20
obj3.GetCellAt(12).DoubleValue = 20; % cell 12 corresponds to 'Par2' in NSCE

Python

# Delete unnecessary object from NSCE
TheSystem.NCE.RemoveObjectAt(3)
# Add detector co-located with another general object
obj3 = TheSystem.NCE.InsertNewObjectAt(3)
DetectorPolar = obj3.GetObjectTypeSettings(ZOSAPI.Editors.NCE.ObjectType.DetectorPolar)
obj3.ChangeType(DetectorPolar)
# Set the detector polar radial size to 20
obj3.GetCellAt(12).DoubleValue = 20 # cell 12 corresponds to par 2 in NCE
Parameters
ObjectNumberThe object number to remove (1 to NumberOfObjects).
Returns
true if the object was successfully remove; otherwise, false.

◆ RemoveObjectsAt()

int ZOSAPI.Editors.NCE.INonSeqEditor.RemoveObjectsAt ( int  ObjectNumber,
int  numObjects 
)

Removes one or more objects at the specified location.

Parameters
ObjectNumberThe first object to remove (1 to NumberOfObjects).
numObjectsThe number of objets to remove.
Returns
The number of objects actually removed.

◆ ReplicateObject()

IMessage ZOSAPI.Editors.NCE.INonSeqEditor.ReplicateObject ( int  ObjectNumber,
int  NumX,
int  NumY,
int  NumZ,
double  DeltaX,
double  DeltaY,
double  DeltaZ,
bool  AddPickupSolves,
bool  RelativeReferences 
)

Replicate the selected object on x, y, and z arrays.

Parameters
ObjectNumberObject # (1-based)
NumXThe number of objects in the X direction
NumYThe number of objects in the Y direction
NumZThe number of objects in the Z direction
DeltaXThe object spacing in the X direction
DeltaYThe object spacing in the Y direction
DeltaZThe object spacing in the Z direction
AddPickupSolvesIf true, all replicated objects will pickup parameter data from the original object.
RelativeReferencesIf true, all replicated objects will use relative references to the original object, otherwise, absolute references are used.
Returns
Null on success; non-null if an error occurred.

◆ SaveDetector()

bool ZOSAPI.Editors.NCE.INonSeqEditor.SaveDetector ( int  ObjectNumber,
string  fileName 
)

Saves the data currently on an NSC Detector Rectangle, Detector Color, Detector Polar, or Detector Volume object to a file.

Usage (see Example 08 for a full sample)

C#

// Save detector data -- allows ray trace results to be loaded later
// For detector polar, the file type is .DDP; for detector rectangle, it is .DDR
string DetectorPolarFile = TheApplication.ZemaxDataDir + "\\Samples\\API\\CS\\detector3polar.DDP";
string DetectorRectFile = TheApplication.ZemaxDataDir + "\\Samples\\API\\CS\\detector4rect.DDR";
TheSystem.NCE.SaveDetector(3, DetectorPolarFile);
TheSystem.NCE.SaveDetector(4, DetectorRectFile);

C++

// Save detector data -- allows ray trace results to be loaded later
// For detector polar, the file type is .DDP; for detector rectangle, it is .DDR
_bstr_t DetectorPolarFile = TheApplication->ZemaxDataDir + "\\Samples\\API\\CPP\\detector3polar.DDP";
_bstr_t DetectorRectFile = TheApplication->ZemaxDataDir + "\\Samples\\API\\CPP\\detector4rect.DDR";
TheSystem->NCE->SaveDetector(3, DetectorPolarFile);
TheSystem->NCE->SaveDetector(4, DetectorRectFile);

Matlab

% Save detector data -- allows ray trace results to be loaded later
% For detector polar, the file type is .DDP; for detector rectangle, it's .DDR
DetectorPolarFile = System.String.Concat(TheApplication.ZemaxDataDir, '\Samples\API\MATLAB\detector3polar.DDP');
DetectorRectFile = System.String.Concat(TheApplication.ZemaxDataDir, '\Samples\API\MATLAB\detector4rect.DDR');
TheSystem.NCE.SaveDetector(3, DetectorPolarFile);
TheSystem.NCE.SaveDetector(4, DetectorRectFile);

Python

# Save detector data -- allows ray trace results to be loaded later
# For detector polar, the file type is .DDP; for detector rectangle, it's .DDR
DetectorPolarFile = TheApplication.ZemaxDataDir + "\\Samples\\API\\Python\\detector3polar.DDP"
DetectorRectFile = TheApplication.ZemaxDataDir + "\\Samples\\API\\Python\\detector4rect.DDR"
TheSystem.NCE.SaveDetector(3, DetectorPolarFile)
TheSystem.NCE.SaveDetector(4, DetectorRectFile)
Parameters
ObjectNumberThe object number of the detector.
fileNameName of the file to save.

fileName may include the full path, if no path is provided the path of the current lens file is used.

The extension should be DDR, DDC, DDP, or DDV for Detector Rectangle, Color, Polar, and Volume objects, respectively.

Returns
true if the operation succeeded; false otherwise.

◆ SetActiveSurface()

bool ZOSAPI.Editors.NCE.INonSeqEditor.SetActiveSurface ( int  SurfaceNumber)

Sets theActiveSurface to the specified surface.

Parameters
SurfaceNumberThe surface number.
Returns
true if the specified surface ZOSAPI.Editors.LDE.SurfaceType is ZOSAPI.Editors.LDE.SurfaceType.NonSequential; otherwise, false.

◆ ShowNCE()

bool ZOSAPI.Editors.NCE.INonSeqEditor.ShowNCE ( )

Shows this editor in the UI. Note that this only has an effect if the IOpticalSystem.Mode is ZOSAPI_Mode.Plugin.

Returns

Property Documentation

◆ ActiveSurface

int ZOSAPI.Editors.NCE.INonSeqEditor.ActiveSurface
get

Gets the active non-sequential surface number for the current INonSeqEditor instance.

The active surface.

◆ FirstColumn

ObjectColumn ZOSAPI.Editors.NCE.INonSeqEditor.FirstColumn
get

Gets the first available column.

The first column.

◆ LastColumn

ObjectColumn ZOSAPI.Editors.NCE.INonSeqEditor.LastColumn
get

Gets the last available column.

The last column.

◆ NumberOfObjects

int ZOSAPI.Editors.NCE.INonSeqEditor.NumberOfObjects
get

Gets the number of objects on the current non-sequential component group.

The number of objects.

◆ RowToObjectOffset

int ZOSAPI.Editors.NCE.INonSeqEditor.RowToObjectOffset
get

Gets the offset from a row to a object (always 1).

The row to object offset.

Connect with Ansys