Find out how you can save time and energy using the Zemax Programming Language!
- 134 Topics
- 363 Replies
Retrieve current object number in NS with macro
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
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
A macro for grid distortion using centroid and shown in image coordinate
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
Exporting volume detector data
Hi, I'm quite new to Zemax and was wondering if someone could assist me with processing some volume detector data. I'm currently trying to reconstruct some data from the volume detector and display it in 3D using the Voxel Maker macro. However, the process tends to be quite slow and often crashes with large models. I've written a Matlab script that will pass a binary array and compute the 3D voxelization. However, I need a way of exporting all of the detector cross-sections from Zemax, so that they can be passed by the script. Does anyone know of a way I can do this? I know I can save the individual images seperately within the detector viewer, however, these images will contain the legend and axis titles. It will also be very time-consuming doing this for 100+ cross-sections. Any help would be greatly appreciated! Regards, Callum Here's the link to the macro I was using for reference: How to show Detector Volume data in 3-D · MyZemax
NSDE Data# not working as expected
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
psf data values in um apart
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.
Print statements in ZPL are suppressed during the script is running
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.
How to detect by source location?
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 ...
Change source array radius of a source file by multi-configuration operands
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
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
GETPSF General Error
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?
Ignore errors in ZPL
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,
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 :)
2D-Vignetting for off-axis optics
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
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.?
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.