Skip to main content
Solved

Can GetDirectFieldCoordinates be passed an array


s.ng
  • Monochrome
  • 4 replies

In the OpenBatchRayTrace tool, for AddRay it appears Hx, Hy, Px, Py can be arrays.  But when I pass the same arrays to GetDirectFieldCoordinates, it gives an error: No method 'GetDirectFieldCoordinates' with matching signature found for class 'ZemaxUI.ZOSAPI.Tools.BatchRayTraceTool'.  It runs fine if I pass single values to Hx, Hy, Px, Py.

 

Can GetDirectFieldCoordinates take arrays, and if so what’s the format? Thanks

Best answer by Allie

Thanks Michael!

@s.ng - are you by chance looking at sample #22 in our ZOS-API Sample Code folder? In that sample, Hy is initially defined as an array, but you will see later in the code that we pick out elements from that array when defining the ray trace. The very first FOR loop is cycling through the values of the Hy array. So as Michael said, we will always use double-type values for Hx, Hy, Px, and Py. 

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

2 replies

MichaelH
Ansys Staff
Forum|alt.badge.img+2
  • Ansys Staff
  • 352 replies
  • June 3, 2022

Hmm, this is strange since the AddRay() method doesn’t accept an array in a native .NET language like C#.  There are several AddRay() methods for each of the different types of ray traces (direct/normalized and pol/unpol) so I wonder if there is either an intermediate step Matlab has when the method might be ambiguous.  Also, even though an error is thrown by Matlab, can you confirm that the NumberOfRays property has the correct value after passing an array to the AddRay() method?


Allie
Zemax Staff
Forum|alt.badge.img+2
  • Zemax Staff
  • 338 replies
  • Answer
  • June 10, 2022

Thanks Michael!

@s.ng - are you by chance looking at sample #22 in our ZOS-API Sample Code folder? In that sample, Hy is initially defined as an array, but you will see later in the code that we pick out elements from that array when defining the ray trace. The very first FOR loop is cycling through the values of the Hy array. So as Michael said, we will always use double-type values for Hx, Hy, Px, and Py. 


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