Find out how you can save time and energy using the Zemax Programming Language!
- 125 Topics
- 320 Replies
Hello together,I’m trying to save Ray Database ZRD to a file in a loop for each angle in the following script:...for angle, -10, 10, 2 x = NSDD (1,0,0,0) SETNSCPOSITION 1,2,6,angle PATHRAY$ = "Rayfile_" + $Str(angle) + ".ZRD" NSTR 1,0,1,1,1,1,1,1,PATHRAY$,"h133",1 UPDATE ALL PAUSE THREADSNEXT This just a part of my script, and exactly this part, namely the saving of ray database is not working. How can I save it, so I could have a few Ray Database files for different angles and open it later with the Ray Database Viewer? What is wrong here?Thank you in advance!CheersMax.
Hello, I would like to use a macro to save images from Geometric Bitmap Image Analysis for different configuration.I wrote this macro in ZPL to save the images obtained for different configurations but it doesn’t work:! Read the # of configsNCONFIG = NCON()!Read pathsettingfiles$ = "...\Zemax\Configs\IMB.CFG"! Execute for each configFOR i, 1, NCONFIG, 1 ! Set config SETCONFIG i img_file$ = $STR(i) + ".png" MODIFYSETTINGS settingfiles$, GBM_OUTPUT, img_file$ OPENANALYSISWINDOW "IBM" PAUSE THREADS NEXTPRINT "DONE!"The configuration changes and the Geometric Bitmap Image Analysis window opens up and displays the right image but nothing is saved. Moreover, the output file name keeps the initial name and it isn’t modifying for each configuration. Do you have any idea to save those images ? (the folder path doesn’t matter) I also wrote another ZPL macro which works and saves the image of the opened window following the different configuration but it still not really what
HiI'm trying coding a ZPL script to create an automatic optimization wizard table.My target optimization wizard table was show as below picture. Here is producing optimization wizard table by running my ZPL script.Unfortunately, they have three differences by comparing the two created optimization wizard tables and making numbers on the above pictures. Here is a list of the parameter value for differences. This is show the partial screenshot of my ZPL script, the code also attached to set Merit Function.zip. What kind the command settings/paraments were missing in this ZPL script? That can be fixed for the three differences.
Hello,I’m trying to simulate a PTFE Integrating Sphere using the predefined macro that we can find in sample files ...\Zemax\Samples\Non-sequentional\Miscellaneous\Integrating Sphere.zmxI was able to change dimension of sphere and port but im finding the following problem:1. How can I change the material MIRROR in PTFE?2. Can I inserti a material inside the sphere?3. How Can I calculate the number of refraction inside the sphere and the number of photons that reach the detector?4. How Can I simulate the Homogeity inside the Sphere?5. The detector viewer doesnt work, how me always the same results….Why?A guide about simulating an integrating sphere can help me so much...Thanks for the support.The code is as attachments.Best Regards.
Is there a way to to use the GETTEXTFILE function with an NSC detector? I’m running into the same issue, and couldn’t figure it out from the help page of the function. I’m currently using SAVEWINDOW from a detector window opened to the text tab and getting the same message.[Mod note: moved the post to a new forum thread.]
Does anyone have an example of setting pickups via the ZOS api in NSC mode?for i in obj_list: obj = NCE.GetObjectAt(i) obj.Xposition.SetPickupfromObject(1) ??? something like this I have over 100 lines in the editor I’d like to set to pickup a position off of an existing object, and manually clicking all of them is tedious. Thank you,Jason
Hi! I’m calculating the energy inside a surface with LEDS with different detectors: volume detector, sphere as detector, volume pipe as detector… but I can’t get the same values across them… I don’t know why if I hace the same system…From objects as a detector I get total power, but from volume detector total flux (all of them in mW); is this the same?When I take a value from the matrix in volume detector, what is this? flux, power¿?This is my file, I calculate the three detectors individuallyThanks in advance,Carmen
Hey Community,I’m starting this thread as a place to document some of the “pitfalls” of the ZPL language. The ZPL is extremely powerful but since OpticStudio is trying to create a new language, the parsing is sometimes problematic.Variable NamesYou can actually assign a value to a number (the ZPL treats the number as a variable name). So while OpticStudio won’t throw an error, you should be very careful when picking variable names:PRINT 1 + 2 # answer is 31 = 2PRINT 1 + 2 # answer is 4FOR LoopsThere is always round-off when dealing with decimals and this becomes especially true when trying to use a decimal step size in a FOR loop. Rather than using decimals as either the start, end or step size, you should keep these as integers and convert to decimals inside the FOR loop:RecommendedFOR i = 0, 10, 1 px = i / 10NEXT Not RecommendedFOR i = 0, 1, 0.1 px = iNEXTSpeed Up CalculationsAll calculations via the ZPL force an update to both the GUI and the core code. Pushing data to t
Hi Zemax Community, I have a quick question, is there a command for deleting all solves in the lens file using ZPL? I wasn’t able to find any resources. Would appreciate if someone can point me to the right resources or let me know what command I should use. Thanks![Mod note: moved to more appropriate forum for ZPL-related discussions.]
Dear Experts,I am trying to read FICL in ZPL. Being new to ZPL I have simply tried this: vec1(1) = 1vec1(2) = 1vec1(3)=1vec1(4)=1vec1(5)=0vec1(6)=0.0366vec1(7)=0vec1(8)=0vec1(9)=0vec1(10)=0vec1(11)=0vec1(12)=0vec1(13)=0vec1(14)=0vec1(15)=0vec1(16)=0vec1(17)=0vec1(18)=0vec1(19)=1f=FICL(1)PRINT "FICL=",f, However, this returns always zero. I could not find any example or any more detailed explanation of ZPL FICL. Are there also several values returned by FICL, like SYSTEM and RECEIVER Efficiency? Can I set the specific configuration to return FICL?Many thanks for some explanation or a hint to an example file.Markus
Hi, I’m a bit confused that when I run the quickfocus command in ZPL, Zemax doesn’t always give me the same value, somehow I had to run my macro twice to get to the correct back focal length (my macro also changed wavelength and field setting). Is it normal to have this? Also, what would be a solution to fix this in the macro? I tried having quickfocus command twice inside the macro but it doesn’t help. Thank you very much.[Mod note: moved to more appropriate forum for ZPL related discussions.]
I have a very simple question. How could I define a source Gaussian out from a single mode fiber, which core size is 4 micro, NA =0.12. I know the beam size (diameter) should be set to be MFD, how to put the parameter for position? should I put the parameter of the position as Rayleigh distance Zr? or should I use MFD/(2*NA)? Thanks for your answer in advance.
Hello,I’m new in OpticStudio and I’m trying to use the macro Mapping Function Resolution created by OpticStudio that we can find here and implement it in my OpticStudio simulation.The modified code is the following: ! Calculate Mapping Function and Resolution! Lorenz Martin, 4 Feb 2020! Get number of system wavelengthsnum_wav = SYPR(201)! Define wavelength rangemin_wav = WAVL(1)max_wav = WAVL(num_wav)delta_wav = 0.01num_wav_steps = INTE((max_wav - min_wav)/delta_wav) + 1! Define variablesDECLARE wavelengths, double, 1, num_wav_steps + 1DECLARE y_positions, double, 1, num_wav_steps + 1DECLARE wavelengths_for_d, double, 1, num_wav_stepsDECLARE d_wavelengths, double, 1, num_wav_stepsDECLARE d_y_positions, double, 1, num_wav_stepsDECLARE resolution, double, 1, num_wav_steps! Set MC operand to change Wavelength 1SETMCOPERAND 1, 0, "WAVE", 0! Loop to go through wavelength range and find position of beam on detector with respect to central wavelengthFOR i, 0, num_wav_steps, 1 wavelength = min
Hi, I am trying to calculate multimode fiber coupling efficiency by using Geometric Image Analysis through GETTEXTFILE, and I want to do this for different fields and wavelengths. I am trying to change field# and wavelength# by MODIFYSETTINGS, but looks like these two parameters are not allowed to be changed. Following is the list of parameters that MODIFYSETTINGS provides: I wonder if anyone knows how to make the changes so I can do this calculation using ZPL. Thanks!Jizuo
Hello all,I am a student in internship and I need to use ZPL to automate my system. I have a system with LED, which I am optimizing. After this optimization I have to measure the power received on the detector for different Z positions (34 positions).I do not know how to make a list of my different Z positions, how to change the value of the Z position for my detector and how to retrieve the value of the power received on my detector.Thank you in advance,Léo
How to iteratively change the clear semi-diameter of a component and save the resulting wavefront map to a file?
Hi everyone, I’ve recently started using OpticStudio. Currently, I’m trying to incrementally change the clear semi-diameter of a surface within my system. I know this can easily be achieved with a FOR loop.However, for each iteration, I hope to save the resulting wavefront map. Unfortunately, using GETTEXTFILE within a loop does not appear to work as intended, as the FOR loop seems to run as normal, but does not create the required files. I’ve attached my code. If there’s any mistakes or changes that need to be made so that the solver iterates over the semi-diameter values and saves the wavefront map at each step, just let me know. ! Setting the desired format.FORMAT 1 INTFOR i, 0, 6, 1 ! Reducing the clear semi-diameter by 5 lens units per iteration. CLR_SEMI_DIAM = 52 - i*5 ! Returning the new clear semi-diameter to the editor. SOLVERETURN CLR_SEMI_DIAM ! Setting the output filename. FLNM$ = "F:\LGS_104_Wavefront_Map_" + $STR(i) + ".txt" ! Writing the wavefront m
Hello,How can I obtain the intensity of single rays (either using ZPL or API) when the apodization is part of a user-defined surface?I used the “us_filt1.dll” example provided with the Zemax distribution and set G>0. The APOI(x,0) operand returns 1.0 for all positions of the pupil (0<x<1), despite the apodization applied in the dll. Thanks!
How can only OBJECT's Clear Semi-Diameter be enlarged? I mean, I want to increase the size of the object's Clear Semi-Diameter without changing the size of the remaining Lens Surface. Can I know how with below System Explorer Setting? 1. Aperture Type "Float by Stop Size"2. Ray Aiming is "Paraxial"3. Convert Semi-Diameters to Circular Properties in the Lens Data Editor4. Change the field type to 'Object height'.
such as fist type i used the filed tpye is real image heightbut i want to convert the type to angle through the macro commandSYSP 100,0however it convert result is the field type is angle but the field datas is not changelike the filed data in No. 12 is 3.4mm in real image heightbut after convert the filed data in No. 12 is 3.4° in anglei want to get the results are similar ,the field datas follws the field type
Good afternoon.I have a question about working with numeric variables when writing an ZPL macro. Is it possible to round the values assigned to variables with the required accuracy? I'm looking for functions similar to (FLOOR.MATH) and (CEILING.MATH) in Microsoft Excel. I understand that i can create a loop that allows me to sequentially compare the value of interest with i and i+1 value. I would like to create an ZPLM operand using rounding, so it seems to me that this way will slow down the optimization, especially with a high degree of rounding accuracy.As an example, we can discuss the case where the value 24.432 needs to be rounded up to 24.0 or 24.5.
Hi! I just started using the ZPL and what I would like to do is to create a solve based on a very simple geometrical relation. But, for doing this, I need to get the Tilt Y of a rectangular object (I am in NS mode).The only think I found is the numeric function NPAR, which it seems to me it only acquires parameters.What would be the right way to do it?Thank you!!!
Enter your username or e-mail address. We'll send you an e-mail with instructions to reset your password.