Solved

Detectors array

  • 18 July 2022
  • 1 reply
  • 153 views

Hi!

I woukd like to know if it’s possible to create a detectors array.

Thanks

icon

Best answer by David.Nguyen 18 July 2022, 14:37

View original

1 reply

Userlevel 7
Badge +2

Hi Carmen,

 

Unfortunately, the Array object that enables creating arrays of objects has the following limitation (from the Help File):

The parent object may be any object type, except for a source, detector, or another array object

 

However, with a macro, you could automate the creation of Detector Rectangles. I’ve made a dummy example for you (that is also attached to my post):

# Number of detectors along X-axis
array_x_size = 3

# Number of detectors along Y-axis
array_y_size = 2

# Spacing between detectors along X-axis
x_spacing = 3.0

# Spacing between detectors along Y-axis
y_spacing = 5.0

# Loop over the array
FOR x_index, 1, array_x_size, 1
FOR y_index, 1, array_y_size, 1
# Create new object at the begining of the NSCE
INSERTOBJECT 1, 1

# Change new object to Detector Rectangle
SETNSCPROPERTY 1, 1, 0, 0, "NSC_DETE"

# Update Detector position
x_position = ( x_index - 1 ) * x_spacing
y_position = ( y_index - 1 ) * y_spacing
SETNSCPOSITION 1, 1, 1, x_position
SETNSCPOSITION 1, 1, 2, y_position

# Change common Detector parameters:

# Number of X Pixels
SETNSCPARAMETER 1, 1, 3, 10

# Number of Y Pixels
SETNSCPARAMETER 1, 1, 4, 10
NEXT
NEXT

If you run this macro (you need to save it in your {Documents}\Zemax\Macros\ folder, and in OpticStudio press Programming..Edit/Run.. select the macro and press Excecute), it’ll give the following result:

I hope this helps, and take care,


David

Reply