Find out how you can save time and energy using the Zemax Programming Language!
- 130 Topics
- 348 Replies
I am using a ZPL script to determine COM positions of many spots with the CENX,Y operant. To set the field positions, I need the 'SETSYSTEMPROPERTY' command followed by an 'update'. Now it turns out that the 'update' requires by far more time than all the ray-tracing. This causes huge runtime issues. My script is running for weeks. Is there a more efficient way to set the field positions in ZPL w/o an 'update'command?
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.?
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!
Hi, I've recently experienced an issue when using ZPL/Zrdplayback command for optimizing a non sequential system. The local optimizer/orthogonal descent, worked fine, but the two global optimizers (Global search & Hammer) stopped at the start of the optimization process with the following error message 'Unable to save file...'. I've found a design file in this forum showing the same behavior (please check the attached file). I suspect that the problem arises when several variations of the initial model are generated and attempt to create and/or read the rayfile from the ZPL macro. Could you please comment and propose a fix that would ideally, preserve the call to zrdplayback? Thank you
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
OpticStudio is no different from any other software in using floating-point representation for storing numbers other than integers. Although the accuracy is very high, sometimes a number like 0.7 can be stored internally as a very close approximation, like 0.700000000001712 or 0.6999999999998394 for example. For calculations these differences are usually acceptable. The differences are generally confined to the digits near the limits of double precision storage anyway. Be very careful, however, using numbers like these in a comparative, like checking if a variable is less than another. In Zemax Programming Language (ZPL), OS operands, and some types of displays (bar charts), particularly with discrete data divisions, you might see unexpected results. For instance, in the following code, there is a big difference between A being 7.1 and A being 7.099999999981728. IF A >= 7.1 PRINT 'Success' ELSE PRINT 'Fail' For similar reasons, the use of non-integers as indices in a FOR-
Is it possible to calculate the 'field Type' 'Angle' (Code 0) from the 'field Type' 'Real Image Height' (Code 3) with a ZPL script? It is basically what the Zemax 'Field data editor' offers with the 'Convert to' option. However, I do not need to *convert* the field type, but just have to determine the value. With 'Single Ray Trace' as well as with the operand 'RAID', I only get one angle. But I need the two angles as defined for the 'field Type' 'Angle' Thank you and best regards, Christof.
Hello, I am trying to run a polarization analysis on a system and am using different polarization states as input. I have created a macro that does this by first using 'POLDEFINE' to define a polarization state, and then using the CODA function to get the information I need. I then use the 'POLDEFINE' function again to describe a new polarization state, and the use the CODA function again. Though, this is unfortunately not working. For some reason, all data sets are the exact same. I am curious how the POLDEFINE is actually working. Are the CODA and POLDEFINE functions possibly decoupled? And if so how do I go about changing the system input polarization using the zpl?
I am currently tyring to run a macro from the command line of my computer. The macro includes the command : >>> OUTPUT 'exampleFile', APPEND This is used to create an output txt file by the name of 'exampleFile.' Now, when I run this macro through the command line, no file is generated. But, when this macro is run through optic studio, there is a file that is generated named exampleFile. I don't understand why this step is ignored when the macro is used through the command line?
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
I am trying to generate a compound lens with front and back surfaces made up of two Biconic Zernike surfaces. One of the aspheric parameters on the front biconic surface is generated by a ZPL macro. When building this model, the compound lens ignores the value provided by the ZPL solve, treating it as it were zero. Is there any way to pass the surface generated by the macro solve to the compound lens without having it be ignored?
I would like to create a new text file from inside of a ZPL macro for saving data while the macro runs. I see the OPEN command, but it requires the file to already be created. I do not see any keyword for creating the new file. Is there a way to create new files from inside of a running Macro? Thanks Chris Buchholz
Hello. I guess my question is fairly straight forward. However, I am not very used to any optimization procedures, so any help will be appreciated. Assuming I have a source and a detector, and some surfaces inbetween in a non-sequential setting. I need to write a merit funtion that maximizes flux on the detector - but only for rays hitting a specific surface in between source and detector. While this is easily done by filter strings in a simple detector view, I was unsure on how to implement this in the optimization. Therefore Zemax provided some help a while ago in form of this ZPLM operand detector = PVHX() clear = NSDD(1,0,0,0) NSTR 1, 0, 0, 0, 0, 0, 0, 1, 'Test.ZRD', 'H4' ZRDPLAYBACK 'Test.ZRD', 1, detector, 1 X = NSDD(1, detector, -3, 0) OPTRETURN 0, X So I specify my detector in H(x) and then clear all detectors, run a raytrace with the filter string applied (in this case hit surface 4) and point it back to the detector. So now this returns the rays hitting the detector under con
Dear Zemax team, Could you please help me put the legends showing the color of each line right next to the regarding legend or is there a way to do this with labels? As you can see, the labels do not show the colored line near them. So, it is hard to distinguish which one belongs to which data line. Next graph below is from an article on your webpage about diffractive optics macro and it does not have this problem. Attached in my macro. At the end of my macro , you can see how I call all the plots in a SUB routine. Your urgent help on this would be appreciated! No problem with legends or labels in the knowledge base article plot about diffractive optics below;
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.
I am running Zemax OpticStudio 19.4 SP2 on Windows 10. When I run the following line in a loop in a macro, randomly, some of the files are empty. The non-empty files are correct. GETTEXTFILE OUTPUT_PSF_FILE$, Hps, CFG_FILENAME$, 1 Please help! Thanks, Qiang
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:
I have a lens file open, with some analysis windows open. Using ZPL, I want to loop through and change the .CFG file (this is for a detector window in non-sequential.). I haven't done it yet, but I think this will change the settings: ModifySettings (filename,DVW_FILTER, ‘new_filter_string”, ‘DVR’) , or something like that, once I get the quotes straightened out. However, my question is: How do I force the open analysis window to update with the new .cfg file? In ZPL Macro, there does not seem to be any command like: LoadNewConfig(Filename, WindowNumber). I know I might be able to open a new analysis window, but for reasons of being able to see what is going on, I'll save that for Option B. thanks for your time. John
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
Enter your username or e-mail address. We'll send you an e-mail with instructions to reset your password.