Find out how you can save time and energy using the Zemax Programming Language!
- 136 Topics
- 365 Replies
Using target values from Merit function in ZPL Macro
Is it possilbe to use target values from a merit function in a zpl macro.For example, there are some defined constraints in the optical path length (OPTH) for e.g. 5 different ray deflections (different Hx or Hy) of an imaging system. Can I use these fixed values in the ZPL macro for further optimization?
Set pickup on a surf parameter in a macro.
Hi, I am writing a macro to modify some surface properties and I can't figure out how to define a pickup... Here is what I am trying to do: SRFn (actually a coordinate break) : I use SETVAR to set the parameter #1 to variable SRFn+3 (I want to make it a coordinate break return): I would like to set parameter #1 of this srf by pickup the one of SRFn but I can't find the right ZPL keyword to do that. Any help is welcome.
How to get the column number calling a ZPL macro?
Hi,In a ZPL macro one can get the object number that’s calling the macro as solve with SOSO(1), but how do I get which column that’s calling the ZPL macro?I want to use the same macro for solving both the Z and the Y position of an object so I don’t need maintain two separate macros.Regards,Hans
CodeV to Zemax conversion
Error in converting from CodeV file to Zemax. Maximum length for a string variable is exceeded. Please shorten string and try again SEQ Command: VUX 0.2862643455614489e-9 -0.002507618428442271 -0.01007430775580165 -0.02275146039691922 -0.04038529897597765 -0.06242137400922543 -0.08826487454143517 -0.1181757056085635 -0.1349076575530941 -0.152878222887056 -0.1719304103266932 -0.1914365142446497 -0.2096016968531782 -0.2187861418214183 -0.2257120003786426 How to debug this. Please let me know
Raytracing not accounting for reflections during ZPL macro execution
Hi, I'm writing a macro to calculate ghost foci from focussing optics, and I need a little more flexibility than the built-in function. The way I'm doing this is by adding a mirror surface to the output of a lens system, and then duplicating the optics preceding the lens in reverse order. I'm having trouble with the output of a raytrace after a reflecton off a surface in ZPL, specifically, the direction of the ray does not change (and rays which should converge, diverge), and the ray acts as though the optics are arranged linearly. Calling a single raytrace yields the expected results and accounts for the reflection as it should, but the output from the raytrace command in ZPL does not do this. Do I need to configure the raytrace command in ZPL in a certain way to allow reflections? Any help is greatly appreciated! I've attached the output of a single raytrace and the output of my script which (at this stage) ought to match the raytrace outp
Change solve NSQ parameter from pickup to fixed(off) using Macro
I am looking for ZPL command which change NSQ parameter solve from pickup to fixed(off).There is command SOLVETYPE and code PF_p to remove pickup for sequential but this option not available for NSQ parameter pick up. Any suggestion how to do so?
Surface Property Updating, but results not changing without manual refresh
Hello, I am doing a polarizaiton analysis and am running into an issue when it comes to updating my surfaces. I have a short macro that updates the tilt about x for a coordinate break before a mirror, and the tilt about x for a coordinate break after a mirror. Then, I am using the OPEV function to get the transmission of a surface further in the system. The problem is, when I use the macro to udpate the tilts, the results don't show in the OPEV function unless I manually refresh the results. This will not work for me as I am working with a very large data set and thus need to be able to do it without manually refreshing. Just a simple example of the setup is given below. SETSURFACEPROPERTY 8, 10, 3, 3 # sets the tilt about x before the mirror (surface 9) SETSURFACEPROPERTY 10, 10, -3, 3 # resents the tilt about x for the whole system, esentially just tilting the mirror in the whole system code_coda = OCOD('CODA') # defining the merit function code used to get th
NSC Polygon Object: where is prism_array.zpl macro?
I found a NSC polygon object 'prism_array.pob' that does ALMOST what I want (put a linear array of microprisms on a 'slab' of material), but I would like to generate (micro-)prisms having different angles, spacing, scale, and different thickness 'slabs.' Editing the .POB file shows that it starts as follows with the comment that it was created by a ZPL macro 'prism_array.zpl': '! This polygon object was created by the prism_array.zpl macro ! V 1 82.50000000 50.00000000 0 V 2 82.50000000 -50.00000000 0 V 3 -82.50000000 -50.00000000 0 V 4 -82.50000000 50.00000000 0 R 1 2 3 4 0 0 V 5 82.50000000 50.00000000 10.00000000 ...' But I can't find the prism_array.zpl macro to edit it, see what can be varied, or to use it to generate new prism array .POBs. Can anybody provide a copy of prism_array.zpl, or point me to where to find it? I have the latest OpticStudio release 20.2 (Professional, perpetual), and can't find
ZPL: GETTEXTFILE with and w/o settingsfile
Dear support team, I have problems understanding the behaviour of the PDL statement GETTEXTFILE in combination with the settingsfile: I am using GETTEXTFILE for Huygens PSF simulations. My questions: 1. Which settings are used if no settingsfile is given at all? It seems that in this case the settings that are saved with the 'save' button in the 'Huygns PSF' window are used. Is this correct and always the case? Does it additionaly depend on the 'flag' setting? 2. With flag=2 the settings box for the requested feature should be displayed. This doesn't seem to happen. No setting box appears. Or is this only the case in combination with an explicit settingsfile? I tryed w/o settingsfile. 3. How can I make sure that the current settings in the 'Huygns PSF' window are used for the simulation? Thank you and best regards, Christof. -- DR. CHRISTOF BODENDORF Max-Planck-Institute for Extraterrestrial Physics Division:
"GetNSCPosition" is not recoganize in ZPL
I applied a solve on position z by 'SOLVETYPE'. Then I need to refer to the result of solve, i.e. the position os z. I am trying to using 'GETNSCPOSITION'. According to the EXTENSION DATA ITEMS, this should return the object position and angle and material. However, the viewer shows 'Unknown symbol GETNSCPOSITION.' The similar command 'SETNSCPOSITION' works fine. But not the GETNSCPOSITION. It seems in the editor, it does not recoganize it as a legal command Can anyone help something is wrong? Thanks.
How to scale a section of a lens system from within ZPL?
I need to be able to scale a section of a lens system from surface Sj to Sn from within a ZPL macro during optimization. Surface 3 in this system is in collimated light and initially set to 1.0, and can be changed in optimization to scale S7-S9 without affecting the system. The thing being optimized is the S7-S9 EFL. I tried using this macro with no luck. I found no SETSCALE or similar ZPL keyword. How to do this? Thanks, Mike # ZPL20.ZPL # USE T3 IN LENS FILE AS SCALING FACTOR FOR L1/L2 DOUBLET T3 = THIC(3) # Varies from unity during op R7 = RADI(7) * T3 R8 = RADI(8) * T3 R9 = RADI(9) * T3 T7 = THIC(7) * T3 T8 = THIC(8) * T3 OPTRETURN 0, T3 OPTRETURN 1, R7 OPTRETURN 2, R8 OPTRETURN 3, R9 OPTRETURN 4, T7 OPTRETURN 5, T8
slope error for asphere specification
Hi all Surface slope error is considered by lens manufacturer as an essential specification for asphere production. Unfortunately Zemax doesn't still allow directy tolerancing on slope error and it is suggested that user should write a macro to do it. So, here is my question: Does somebody have such a macro that he/she would be so kind to share? Thank you! Renaud
Suppress Zemax Message during macro execution
Hi, I'm running Zemax Optic Studio Professional, version 20.2.2. Whenever I'm working with large pixel arrays, or high (> 1024 x 1024) sampling in physical optics propagation, and my detector viewer/beam file viewer is set to text view, I get a message box saying 'Text is too long to display. Use Copy All or Save As' to retrieve the entire file'. This message box doesn't cause a problem as I'm exporting the data in a macro anyway, but it means that during a long macro where I'm running POP multiple times, I have to constantly watch OpticStudio as it pauses the macro until I dismiss the message box, which is obviously impractical. Is there a way to either a) Increase the maximum allowed text file to be displayed within OpticStudio, or b) Suppress the message box, as the data export is absolutely fine Thank you!
Use SSAG operand in ZPL Marco
Hi all,I’m trying to use ssag operand to obtain the surface sag in sequential mode. I’m ok with using it in the merit function editor, however, as I have a lot of sampling points, manually inserting ssag function is a real pain. Is there any method to use SSAG in the ZPL Marco where I can write my own loop? Best wishesDaoming
ZPL commands for sensitivity analysis
I’m interested in automating a couple of simple steps using ZPL. I don’t find a reference table of the names of different parameters in ZPL in the Help. How do I print a particular merit function result e.g. CENX at a particular station, and how do I change the value of a Coordinate Break’s “Decenter X” or “Tilt X” etc.?
Diffractive macro DOESAG.zpl is not available
Hi,I am unable to find DOESAG.zpl macro for getting the sag values for the diffractive aspheric surface. Earlier it was available in the knowledge base but now that is also not there. Can I get this macro as it is very useful to view the steps of diffractive surface and surface sag dataRegardsJ Himavanth kumar
Input surface map (Surface Sag) to ZEMAX
Hi all, I am currently doing an optics project with some mechanical simulations. We are trying to simulate the surface deformation with mechanical design software. Then input the data to ZEMAX. If I have a sag data like the attached, could I input these data to get the surface in ZEMAX? Including radius of curvature and aspherical coefficients. Thank you, Raymond
EFNO gives different result to that calclated in relative illumination analysis
Hello,I have a system with a non-circular aperture and therefore try to calculate its effective f number using the operand EFNO(effective f number). However, I get different results when using the operand EFNO, in comparison to the result given in the relative illumination analysis, despite the same setting is applied on both calculation. (wavelength 3 is 0.555µm, and field 1 corresponds to 0 y field) As can be seen above, one gives a value of 4.13(EFNO), while the other gives a value of 3.85. I think the latter one should be correct, but the question is why does one get different results here, do these two use different algorithms for calculation? How can I calculate this value in a Zemax macro conveniently if the result provided by EFNO is not trustworthy…. Thanks a lot in advance!
ZPL Macro for Ray Trace in Mixed mode
Hi,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.
Hello OpticStudio users, Today, I noticed that if I am writting a macro, I need to click on the floppy icon to save it. If I press Ctrl+S, it saves my lens design, but not the macro. This happens even if the focus is on the text editor window of the macro. In other words, if I modify a macro, then press Ctrl+S, and run the macro again, changes are ignored. Am I doing something wrong? I don't remember if it was always the case, but I hope this post will avoid people losing time with this mistake in the future. Take care :)
Already have an account? Login
Enter your username or e-mail address. We'll send you an e-mail with instructions to reset your password.