execute zemax macro with mzdde
Show older comments
I am trying to control Zemax with Matlab's mzdde.
I want to execute a Zemax macro using Matlab but can't figure out how. If the macro window is open and I use zPushLens, it will execute (since all windows are updated) but that isn't a very elegant solution. Someone suggested using the zGetTextFile with "Zpl" as the analysis type, but I don't see how that calls a specific macro.
Does anyone know how to call macros from Matlab?
Answers (1)
Indranil Sinharoy
on 1 Jun 2013
Edited: Indranil Sinharoy
on 3 Jun 2013
1 vote
Try zOpenWindow(ButtonCode). Where the ButtonCode is the first 3 letters of the name of the ZPL macro. Note that the ButtonCode is case sensitive. However, there are certain limitations to this, which are:
1. Currently one can only "execute" a existing ZPL macro without modification.
2. If it is required to redirect the result of executing the ZPL to a text file, modify the ZPL macro in the following way:
(a) Add the following two lines at the beginning of the file:
- CLOSEWINDOW # to suppress the display of default text window
- OUTPUT "full_path_with_extension_of_result_fileName"
(b) Add the following line at the end of the file:
- OUTPUT SCREEN # close the file and re-enable screen printing
3. If there are more than two macros which have the same first 3 letters then all of them will be executed by Zemax.
Hope that helps.
1 Comment
Lydia
on 8 Apr 2015
Hi,I found this thread very helpful, however I have a related question: is there a way to interact with the macro while executing it? I am using a macro that requires user input before it executes further. Thanks!
Categories
Find more on MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!