Solved

Can GetDirectFieldCoordinates be passed an array


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

icon

Best answer by Allie 10 June 2022, 22:20

View original

2 replies

Userlevel 6
Badge +2

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?

Userlevel 6
Badge +2

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