Interface ZOSAPI::Editors::NCE::INonSeqEditor
Last update: 13.03.2026
Definition:
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.
Inherits from:
Members
- ActiveSurface
- AddObject
- AddRow
- AllAvailableObjectNames
- AvailableDetectorNames
- AvailableObjectNames
- AvailableSourceNames
- CopyObjects
- CopyObjectsFrom
- DeleteAllRows
- DeleteRowAt
- DeleteRowsAt
- Editor
- FirstColumn
- GetAllCoherentData
- GetAllCoherentDataSafe
- GetAllColorDetectorData
- GetAllColorDetectorDataSafe
- GetAllDetectorData
- GetAllDetectorDataSafe
- GetAllPolarDetectorData
- GetAllPolarDetectorDataSafe
- GetClosestGlass
- GetCoherentData
- GetColorDetectorData
- GetDetectorData
- GetDetectorDimensions
- GetDetectorSize
- GetGlass
- GetId
- GetIndex
- GetMatrix
- GetObjectAt
- GetPolarDetectorData
- GetRowAt
- HideEditor
- HideNCE
- InsertNewObjectAt
- InsertRowAt
- LastColumn
- LoadDetector
- MaxColumn
- MinColumn
- ModifyReferenceObjects
- NextNSCGroup
- NumberOfObjects
- NumberOfRows
- ObjectNameFromObjectType
- ObjectTypeFromObjectName
- PrevNSCGroup
- ReloadAllObjects
- ReloadObject
- RemoveObjectAt
- RemoveObjectsAt
- ReplicateObject
- RowToObjectOffset
- SaveDetector
- SetActiveSurface
- SetJonesMatrixData
- SetMuellerMatrixData
- ShowEditor
- ShowNCE
Properties
Property RowToObjectOffset
Definition:
int ZOSAPI.Editors.NCE.INonSeqEditor.RowToObjectOffset
Gets the offset from a row to a object (always 1).
The row to object offset.
Return type: int
Property ActiveSurface
Definition:
int ZOSAPI.Editors.NCE.INonSeqEditor.ActiveSurface
Gets the active non-sequential surface number for the current INonSeqEditor instance.
The active surface.
Return type: int
Property NumberOfObjects
Definition:
int ZOSAPI.Editors.NCE.INonSeqEditor.NumberOfObjects
Gets the number of objects on the current non-sequential component group.
The number of objects.
Return type: int
Property FirstColumn
Definition:
ObjectColumn ZOSAPI.Editors.NCE.INonSeqEditor.FirstColumn
Gets the first available column.
The first column.
Return type: ObjectColumn
Property LastColumn
Definition:
ObjectColumn ZOSAPI.Editors.NCE.INonSeqEditor.LastColumn
Gets the last available column.
The last column.
Return type: ObjectColumn
Public functions
Function AllAvailableObjectNames
string[] ZOSAPI.Editors.NCE.INonSeqEditor.AllAvailableObjectNames()
Return type: string[]
Function AvailableSourceNames
string[] ZOSAPI.Editors.NCE.INonSeqEditor.AvailableSourceNames()
Return type: string[]
Function AvailableDetectorNames
string[] ZOSAPI.Editors.NCE.INonSeqEditor.AvailableDetectorNames()
Return type: string[]
Function AvailableObjectNames
string[] ZOSAPI.Editors.NCE.INonSeqEditor.AvailableObjectNames()
Return type: string[]
Function ObjectTypeFromObjectName
ObjectType ZOSAPI.Editors.NCE.INonSeqEditor.ObjectTypeFromObjectName(string objectName)
Parameters:
- string objectName
Return type: ObjectType
Function ObjectNameFromObjectType
string ZOSAPI.Editors.NCE.INonSeqEditor.ObjectNameFromObjectType(ObjectType objectType)
Parameters:
- ObjectType objectType
Return type: string
Function SetActiveSurface
bool ZOSAPI.Editors.NCE.INonSeqEditor.SetActiveSurface(int SurfaceNumber)
Sets theActiveSurface to the specified surface.
Parameters:
- SurfaceNumber: The surface number.
Returns:
true if the specified surface ZOSAPI.Editors.LDE.SurfaceType is ZOSAPI.Editors.LDE.SurfaceType.NonSequential; otherwise, false.
Parameters:
- int SurfaceNumber
Return type: bool
Function NextNSCGroup
bool ZOSAPI.Editors.NCE.INonSeqEditor.NextNSCGroup()
Selects the next available non-sequential surface.
Returns:
Return type: bool
Function PrevNSCGroup
bool ZOSAPI.Editors.NCE.INonSeqEditor.PrevNSCGroup()
Selects the previous available non-sequential surface.
Returns:
Return type: bool
Function 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);
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:
- ObjectNumber: The object number (1 to NumberOfObjects).
Returns:
Parameters:
- int ObjectNumber
Return type: INCERow
Function 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:
- ObjectNumber: The object number (1 to NumberOfObjects+1).
Returns:
Parameters:
- int ObjectNumber
Return type: INCERow
Function 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();
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:
Return type: INCERow
Function 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);
ZOSAPI.Editors.NCE.IObjectTypeSettings 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 always corresponds to 'Par2' in the NSCE
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:
- ObjectNumber: The object number to remove (1 to NumberOfObjects).
Returns:
true if the object was successfully remove; otherwise, false.
Parameters:
- int ObjectNumber
Return type: bool
Function RemoveObjectsAt
int ZOSAPI.Editors.NCE.INonSeqEditor.RemoveObjectsAt(int ObjectNumber, int numObjects)
Removes one or more objects at the specified location.
Parameters:
- ObjectNumber: The first object to remove (1 to NumberOfObjects).
- numObjects: The number of objets to remove.
Returns:
The number of objects actually removed.
Parameters:
- int ObjectNumber
- int numObjects
Return type: int
Function ReloadObject
void ZOSAPI.Editors.NCE.INonSeqEditor.ReloadObject(int ObjectNumber)
Reloads the specified object (for more information, see the OpticStudio manual).
Parameters:
- ObjectNumber: The object number to reload (1 to NumberOfObjects).
Parameters:
- int ObjectNumber
Return type: void
Function ReloadAllObjects
void ZOSAPI.Editors.NCE.INonSeqEditor.ReloadAllObjects()
Reloads all objects in the editor (for more information, see the OpticStudio manual).
Return type: void
Function 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:
Return type: bool
Function 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:
Return type: void
Function 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));
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:
- ObjectNumber: Object # (1-based)
- R11: Row 1, Column 1
- R12: Row 1, Column 2
- R13: Row 1, Column 3
- R21: Row 2, Column 1
- R22: Row 2, Column 2
- R23: Row 2, Column 3
- R31: Row 3, Column 1
- R32: Row 3, Column 2
- R33: Row 3, Column 3
- Xo: X offset
- Yo: Y offset
- Zo: Z offset
Returns:
True for a valid object; False otherwise
Parameters:
- 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
Return type: bool
Function 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:
- ObjectNumber: The object number of the detector.
- Rows: The # of rows in the detector.
- Cols: The # of columns if the detector or rectangular;
1for other detector types;0for invalid inputs.
Returns:
true for a valid detctor number; false otherwise.
Parameters:
- int ObjectNumber
- out uint Rows
- out uint Cols
Return type: bool
Function 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
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:
- ObjectNumber: The object number of the detector.
- pixel: The pixel number on the detector (1-based); use 0 to retrieve the sum over all pixels.
- Data: The desired data type.
- Value: The value.
Returns:
True for a valid detector; false otherwise
Parameters:
- int ObjectNumber
- int pixel
- DetectorDataType Data
- out double Value
Return type: bool
Function 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:
- ObjectNumber: The object number of the detector.
- Data: The desired data type.
Returns:
2D array of the desired data for valid inputs; null otherwise.
Parameters:
- int ObjectNumber
- DetectorDataType Data
Return type: double[,]
Function GetAllCoherentData
bool ZOSAPI.Editors.NCE.INonSeqEditor.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.
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:
- ObjectNumber: The object number of the detector.
- Data: The desired data type.
- numPixels: The number of pixels in the data array; this should match the value returned by GetDetectorSize.
- detectorData: The data array to fill with the desired data.
Returns:
true for a valid detector; false otherwise
Parameters:
- int ObjectNumber
- DetectorDataType Data
- uint numPixels
- [In, Out] double[] detectorData
Return type: bool
Function GetDetectorSize
uint ZOSAPI.Editors.NCE.INonSeqEditor.GetDetectorSize(int ObjectNumber)
Gets the total number of pixels for the specified detector.
Parameters:
- ObjectNumber: The object number of the detector.
Returns:
The number of pixels in the detector (rows * columns).
Parameters:
- int ObjectNumber
Return type: uint
Function 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]);
}
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:
- ObjectNumber: The object number of the detector.
= 0: clear all detectors
0: retrieve data from the detector
< 0: clear the detector.
Parameters:
- pixel: The 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:
- Data: The 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:
- Value: The return value.
Returns:
True for a valid detector; False otherwise
Parameters:
- int ObjectNumber
- int pixel
- int Data
- out double Value
Return type: bool
Function GetAllDetectorData
bool ZOSAPI.Editors.NCE.INonSeqEditor.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.
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:
- ObjectNumber: The object number of the detector.
- Data: GetDetectorData
- numPixels: The number of pixels in the data array; this should match the value returned by GetDetectorSize.
- detectorData: The data array to fill with the desired data.
Returns:
true for a valid detector; false otherwise
Parameters:
- int ObjectNumber
- int Data
- uint numPixels
- [In, Out] double[] detectorData
Return type: bool
Function GetAllDetectorDataSafe
double[,] ZOSAPI.Editors.NCE.INonSeqEditor.GetAllDetectorDataSafe(int ObjectNumber, int Data)
Similar to GetDetectorData, but retrieves data for all pixels at once.
Parameters:
- ObjectNumber: The object number of the detector.
- Data: GetDetectorData
Returns:
The requested data for a valid detector; null otherwise
Parameters:
- int ObjectNumber
- int Data
Return type: double[,]
Function 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:
- ObjectNumber: The object number of the detector.
= 0: clear all detectors
0: retrieve data from the detector
< 0: clear the detector.
Parameters:
- pixel: The 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:
- Data: The 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:
- Value: The return value.
Returns:
True for a valid detector; False otherwise
Parameters:
- int ObjectNumber
- int pixel
- PolarDetectorDataType Data
- out double Value
Return type: bool
Function GetAllPolarDetectorData
bool ZOSAPI.Editors.NCE.INonSeqEditor.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.
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);
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:
- ObjectNumber: The object number of the detector.
- Data: GetDetectorData
- numPixels: The number of pixels in the data array; this should match the value returned by GetDetectorSize.
- detectorData: The data array to fill with the desired data.
Returns:
true for a valid detector; false otherwise
Parameters:
- int ObjectNumber
- PolarDetectorDataType Data
- uint numPixels
- [In, Out] double[] detectorData
Return type: bool
Function 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:
- ObjectNumber: The object number of the detector.
- Data: GetDetectorData
Returns:
The requested data for a valid detector; null otherwise
Parameters:
- int ObjectNumber
- PolarDetectorDataType Data
Return type: double[,]
Function 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:
- ObjectNumber: The object number of the detector.
- fileName: Name 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:
- appendData: If set to
truethen 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.
Parameters:
- int ObjectNumber
- string fileName
- bool appendData
Return type: bool
Function 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:
- ObjectNumber: The object number of the detector.
- fileName: Name 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.
Parameters:
- int ObjectNumber
- string fileName
Return type: bool
Function 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:
- fromObjectNumber: First object number to copy (1 to NumberOfObjects).
- NumberOfObjects: The number of objects to copy.
- toObjectNumber: Row to start inserting the objects (1 to NumberOfObjects+1).
Returns:
The number of objects actually copied.
Parameters:
- int fromObjectNumber
- int NumberOfObjects
- int toObjectNumber
Return type: int
Function 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:
- fromEditor: System to copy the objects from.
- fromObjectNumber: First object number to copy (1 to NumberOfObjects).
- NumberOfObjects: The number of objects to copy.
- toObjectNumber: To object number (1 to NumberOfObjects+1).
Returns:
The number of objects actually copied.
Parameters:
- INonSeqEditor fromEditor
- int fromObjectNumber
- int NumberOfObjects
- int toObjectNumber
Return type: int
Function 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:
- ObjectNumber: The object number of the detector.
= 0: clear all detectors
0: retrieve data from the detector
< 0: clear the detector.
Parameters:
- pixel: The 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:
- angleSpace:
truefor angle space data, otherwise position space data. - Data: The 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:
- numIgnoredPixels: If 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:
- Wavelength: Specifies 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.
- Value: The return value.
Returns:
True for a valid detector; False otherwise
Parameters:
- int ObjectNumber
- int pixel
- bool angleSpace
- int Data
- int numIgnoredPixels
- double Wavelength
- out double Value
Return type: bool
Function GetAllColorDetectorData
bool ZOSAPI.Editors.NCE.INonSeqEditor.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.
Parameters:
- ObjectNumber: The object number of the detector.
- angleSpace: GetColorDetectorData
- Data: GetColorDetectorData
- numPixels: The number of pixels in the data array; this should match the value returned by GetDetectorSize.
- detectorData: The data array to fill with the desired data.
Returns:
true for a valid detector; false otherwise
Parameters:
- int ObjectNumber
- bool angleSpace
- int Data
- uint numPixels
- [In, Out] double[] detectorData
Return type: bool
Function 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:
- ObjectNumber: The object number of the detector.
- angleSpace: GetColorDetectorData
- Data: GetColorDetectorData
Returns:
The requested data for a valid detector; null otherwise
Parameters:
- int ObjectNumber
- bool angleSpace
- int Data
Return type: double[,]
Function 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:
-
first: The number (1-based) of the first object to modify.
-
last: The number (1-based) of the last object to modify.
-
reference: Either
-
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.
Parameters:
- int first
- int last
- int reference
Return type: IMessage
Function 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:
- ObjectNumber: Object # (1-based)
- glassName: The name of the glass
- nd: The nd value
- vd: The vd value
- dpgf: The dpgf value
Returns:
false if the object is not valid, is not made of glass, or is a gradient index; otherwise, true.
Parameters:
- int ObjectNumber
- out string glassName
- out double nd
- out double vd
- out double dpgf
Return type: bool
Function GetIndex
int ZOSAPI.Editors.NCE.INonSeqEditor.GetIndex(int ObjectNumber, int NumberOfWavelengths, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex=1)][In, Out]double[] indexAtWavelength)
Extract refraction data for any object.
Parameters:
- ObjectNumber: Object # (1-based)
- NumberOfWavelengths: The number of wavelenghts to retrieve. Note: this number must be the length of indexAtWavelength.
- indexAtWavelength: When 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.
Parameters:
- int ObjectNumber
- int NumberOfWavelengths
- [In, Out] double[] indexAtWavelength
Return type: int
Function 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:
- ObjectNumber: Desired object (1 to NumberOfObjects)
Returns:
The glass name if found, otherwise an empty string
Parameters:
- int ObjectNumber
Return type: string
Function GetId
long ZOSAPI.Editors.NCE.INonSeqEditor.GetId(int objectNumber)
Parameters:
- int objectNumber
Return type: long
Function 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:
- ObjectNumber: Object # (1-based)
- NumX: The number of objects in the X direction
- NumY: The number of objects in the Y direction
- NumZ: The number of objects in the Z direction
- DeltaX: The object spacing in the X direction
- DeltaY: The object spacing in the Y direction
- DeltaZ: The object spacing in the Z direction
- AddPickupSolves: If true, all replicated objects will pickup parameter data from the original object.
- RelativeReferences: If 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.
Parameters:
- int ObjectNumber
- int NumX
- int NumY
- int NumZ
- double DeltaX
- double DeltaY
- double DeltaZ
- bool AddPickupSolves
- bool RelativeReferences
Return type: IMessage
Function SetJonesMatrixData
void ZOSAPI.Editors.NCE.INonSeqEditor.SetJonesMatrixData(int obj, bool isRetarder, double delta, double angle, double transmission)
Parameters:
- int obj
- bool isRetarder
- double delta
- double angle
- double transmission
Return type: void
Function SetMuellerMatrixData
void ZOSAPI.Editors.NCE.INonSeqEditor.SetMuellerMatrixData(int obj, bool isRetarder, double delta, double angle, double transmission, double dop)
Parameters:
- int obj
- bool isRetarder
- double delta
- double angle
- double transmission
- double dop
Return type: void