Skip to main content
Solved

Detectors array

  • July 18, 2022
  • 1 reply
  • 226 views

Carmen Lago

Hi!

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

Thanks

Best answer by David.Nguyen

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

View original
Did this topic help you find an answer to your question?

1 reply

David.Nguyen
Luminary
Forum|alt.badge.img+2
  • Luminary
  • 1122 replies
  • Answer
  • July 18, 2022

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings