I am facing an issue when I try to extract ray trace data for a non sequential component in mixed mode of Zemax.
In the above data, I want to get the direction cosines of normal and incident ray for NSC object 7 and 2 using a ZPL macro (as I am tracing a 10000 rays). Since for RANX(surface) (Surface number in the sequential editor has to be given) I don’t know which surface number has to given for this case. I also tried to save the ray trace data every time I trace the ray, but When I run RAYTRACE hx,hy,px,py,wav, (for different px and py), somehow the data in the Raytrace text is not getting update. Can you please provide me a solution for this.
Best answer by Jeff.WildeView original
I don’t think it is possible to get the mixed-mode ray data you want using the ZPL RAYTRACE keyword (and subsequent keywords like RAYX), or any merit function operands for that matter, because they only report ray data at a specific sequential surface (not inside an NSC group). In ZPL it is possible to run a single ray trace analysis, identical to what can be done manually inside the model GUI, and save the results to a temporary file using: GETTEXTFILE A$, Rtr (where Rtr is the string code for the analysis function and A$ is the temporary file name). Then, data from a particular line of interest can be extracted from this file; however, it does not appear possible to change the analysis parameters from within ZPL (e.g., Hx, Hy, Px, Py) because the single ray trace analysis is not supported by the MODIFYSETTINGS keyword.
However, you can change the source ray parameters and access the desired ray data using ZOS-API. Here is some sample Matlab code using the Interactive Extension mode of operation:
We can then display the results:
and compare them to the values in the Single Ray Trace analysis window:
Of course this only traces one ray at a time, but with a couple of nested loops, rays spanning the area of the entrance pupil (Px, Py) can be sequentially traced, and the ray parameter values inside the NSC group can be extracted.
Thanks a lot for the solution. I was able to get the ray trace data for many rays through the ZOS-API (Matlab) using a simple loop . I now realize ZOS-API can do many things which ZPL macros cannot!!