Find out how you can save time and energy using the Zemax Programming Language!
- 130 Topics
- 348 Replies
Hello, I would like to retrieve current object number in Macro while I choose ZPL macro in solveing type of x position in pure NS editor. I check Manual and found there is a function that can get the object number. NPRO(surf, object, code,face), but the object parameter in this function is object number which is what I want to retrieve. How can I retrieve current object number in NS mode while I write ZPL code? Best regards Kevin
A user asked why when using ZPL macro to save the Cross Section Row Coherent Irradiance data from Detector Viewer, the .txt file he got does not match the information displayed in the Text tab of the Detector Viewer. Instead of seeing a 2-column data of X position versus Irradiance, he kept seeing 3-column data displaying “Spatial Frequency, X and Y” This is because in his code, the Configuration file is saved with the settings displayed in the Graph tab of the Detector Viewer, where the Cross Section Row is data value #4 in the “Show As:” dropdown list, (the index starts at 0). However, the GETTEXTFILE keyword is retrieving data from the Text tab of the Detector Viewer, where there isn’t a data value #4 in the “Show As:” dropdown list, so OpticStudio simply saves the data from the last available data value #3 which is the “Geometric MTF”. In order to save the data for the Cross Section Row irradiance, you need to use MODIFYSETTINGS
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
This code calculates grid distortion based on centroid. The advantage is it works for systems where the chief ray cannot reach image surface. Note that, although chief ray doesn't need to reach image surface, there should still be some rays reaching the image surface. This only works when the field type is either Angle or Object Height. Another useful points of this tool is it shows data on image coordinate, not object coordinate as in the native Grid Distortion analysis.In the generated layout, you can see red and blue marks.Red marks are the centroid position of each sampled field. Blue marks are the 'reference' that serves as definition of 'no distortion'.Note Red marks are the ray-tracing result of your system and cannot be changed. However, the blue marks is defined by ABCD matrix, which can be user-defined. In other words, there is no a standard of 'no distortion'.The macro will automatically find a reasonable ABCD matrix just like the native Grid Distortion, but you can definit
Can you confirm the Data# field of NSDE is not working as expected, both in ZPL and MF? Help reference: The Optimize Tab (non-sequential ui mode) > Automatic Optimization Group (optimize tab, non-sequential) > Merit Function Editor (optimize tab, non-sequential) > NSC Operands I expect the following to work in fully non sequential mode: ! Detector color object reference det = 4 TotalFlux = NSDE(1,det,0,0,0,0) MaxIrradiance = NSDE(1,det,-1,0,1,0) But actually, the following work for me, i.e. return the correct quantity: TotalFlux = NSDE(1,det,0,0,1,0) MaxIrradiance = NSDE(1,det,-1,0,2,0) Therefore, if this is confirmed, the Data# reported in the table of the Help is wrong and should be incremented by 1. Thank you
when i use getpsf in zpl, the result mentioned that there are np data points, and spaced by micrometers apart. what does it mean? Is it the average position between the psf data points? also, the data spacing reduces as pupil sampling increases. do you have some references for me to better understand this results.
Dear support team, it seems that a 'Print' statement in ZPL is suppressed during the script is running. Then at the end of the script all print statements are executed at once. I guess, this is a kind of optimisation? However, I am running large scripts and I would like to see the progress in the command window . So I would like the print statement to react directly when it is called. Is this possible? Thank you, Christof.
I am using FLDX,FLDY to get the current field angle. Now, I find in the Help: These commands are obsolete. See “SETSYSTEMPROPERTY, SYSP”. But SETSYSTEMPROPERTY is to *set* properties of the system, not to *read* them. So how do I access the current field angle now? Best, Christof.
I am using non-sequential mode. And I want to detect by automatically moving the location of the source by 1mm. How to write zpl file? I want to figure out the number of hits by point source location. Ex) point source location(0,0,0) >> clear & trace >> point source location(1mm,0,0) >> clear & trace >> point source location(2mm,0,0) >> clear & trace >> point source location(3mm,0,0) >> clear & trace ...
Hi! I am trying to set up a system with different configurations of a light source. The light source is defined by a source file and set up as a circular array with a certain radius. I would like to change the radius of this circle between different configurations of the system. Is there a way to reach this radius parameter by a multi-configuration operand? The ZPL function SETNSCPROPERTY seems to have a way to reach in and do this. SETNSCPROPERTY (keywords) Sets properties of NSC objects. Syntax: SETNSCPROPERTY surface, object, code, face, value Code Property The following codes set values on the Sources tab of the Object Properties dialog. 112 Sets the array mode; 0 for none, 1 for rectangular, 2 for circular, 3 for hexapolar, and 4 for hexagonal. 165-166 Sets the array mode double precision arguments 1 and 2. I have tried to set this with the NPRO operand
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
I have a macro calling GETPSF for various thicknesses to the focal plane, and I am getting np = -3, 'General Error' returned when I use Gaussian apodization. I have checked that the FFT PSF is calcualting without error for the same thicknesses as are in my macro. What else can cause a 'General Error' in response to a call to GETPSF?
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 :)
Is there a way to ignore errors while running a ZPL, and keep it running? I have a ZPL that opens files and some files come up with the following error. Zemax Error Message Cannot determine object coordinates! OK I select OK and the ZPL can continue running. But since I am running through many files this comes up often and doesn't continue until I select OK. Is there a way to ignore these errors and allow a ZPL to continue running? Without having to select OK each time? Thank you,
Dear support team, I am working with a complex off-axis optics with several stray-light baffles. I need to determine the vignetting as a function of the two field coordinates. The first surface of my afocal system is the aperture stop. With vignetting I mean a geometrical quantity defined as the number of rays from one field that reach the image divided by the number of rays that pass my aperture stop. I think this is basically what the Zemax 'Vignetting Plot' does. But: 'This feature is appropriate for rotationally symmetric lenses and fields' only. The Footprint Diagram determines the 'percentage of rays through', which should be the same. Is this correct? Is there an Operand available, that calculates the vignetting according to what these two plots do and which I can calculate over a 2D-field with ZPL? I found the IMAE Operand: 'The IMAE operand estimates the efficiency of an optical system by launching many rays into the entrance pupil; computing the fraction of rays t
Hello! When calculating the FFT PSF, I sometimes get the error message 'Computation aborted, invalid results'. When I change the PSF sampling, the error disappears. It is probably linked to a user defined surface (based on the multizone asphere surface example) combined with specific values of decentrations of the optical elements. Do you have any ideas about the meaning of the error-message and how to debug it / get rid of it? I am saving the FFT PSF window within a ZPL macro. Is there a way to do error-handling in the ZPL macro? (E.g. if the error occurs, the sampling of the FFT PSF calculation will be decreased and the calculation repeated...) Thank you!
Enter your username or e-mail address. We'll send you an e-mail with instructions to reset your password.