Skip to main content
Question

ZPL Detector Viewer Update


Hi,

I would like to use zpl to update my detector viewer and save it as an image.

However, neither Ray Database nor Filter are adjusted in the detector viewer.

#trace rays & evaluate Detector

filter$ = "h3&h6&!x_hitface(8,0)&!x_hitface(8,2)&!x_hitface(4,0)&(x_hitface(7,1)|x_hitface(7,0))"
filter2$="h3&h6&!x_hitface(8,0)&!x_hitface(8,2)&!x_hitface(4,0)"
fileName$ = "ZMPRays.ZRD"

NSTR 1, 0,0,0,0,1,0,1,fileName$
temp = NSDD(1,0,0,0) 
ZRDPlayback fileName$,1,0,1, filter2$
UPDATE ALL
PRINT NSDD(1,9,0,0)
ZRDPlayback fileName$,1,0,1, filter$
UPDATE ALL
PRINT NSDD(1,9,0,0)

settingsFile$= "...\Zemax\Configs\DVR.CFG"
MODIFYSETTINGS settingsFile$, DVW_ZRD, fileName$
MODIFYSETTINGS settingsFile$, DVW_FILTER, filter$
UPDATE ALL

The  PRINT NSDD(….) commands give the correct outputs, but the detector viewer is not updated.

How can I use ZPL to update the detector viewer using the Ray Database fileName$ and the filter string filter$?

5 replies

David.Nguyen
Luminary
Forum|alt.badge.img+2

@simon.schroeder_01 

 

Did you see this?

Take care,

 

David


David.Nguyen wrote:

@simon.schroeder_01 

 

Did you see this?

Take care,

 

David

Yes, that’s why I went through the text variables filter$ and filter2$.
I get the right results witht NSDD command, but for the detector viewer, the filter string is not applied.


David.Nguyen
Luminary
Forum|alt.badge.img+2

@simon.schroeder_01 

 

It might be interesting to see if you can get it to work with 2024 R1.0 to see if its related.

Take care,

 

David


MichaelH
Ansys Staff
Forum|alt.badge.img+2
  • Ansys Staff
  • 368 replies
  • June 18, 2025

In 25R1, if I run a very simple simulation with a source, rectangle, and detector where the rectangle blocks half the source, I get the expected results with ZRDPLAYBACK.

Using the following ZPL script, I get the left image when I don’t use a filter string and on the right image when I use an H2 filter.

! user defined filters
filter1$ = "H2"
filter2$ = ""

! run raytrace
fileName$ = "test.ZRD"
NSTR 1, 0, 0, 0, 0, 1, 0, 1, fileName$
ZRDPLAYBACK fileName$, 1, 0, 1, filter2$

! update Detector Viewer window
UPDATE ALL

So I believe the filter strings are working in 25R1 (also 24R2).

Which OpticStudio version are you using?  Can you upload a paired down ZAR file along with your ZPL macro?


Thank you for the example file.
I was using 23R2 and your example did not work.
I have updated to 24R2 and it still is not working for me:

I do get the same images as you only if the detector Viewer has <No Ray Database Selected> selected.
It has the overlay message “Ray trace has not been run”

If it has the “test.ZRD” ray-database, I do not see the filter.

Is the problem “only” to get rid of the  banner?

 


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