Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    joservargasr
    @joservargasr
    Note that an extension should never request that more rays be traced at one time than can be traced within
    the timeout period specified in the zclient.c code. Within zclient.c there is a constant called DDE_TIMEOUT that
    has a value of 5000 (the units are milliseconds, so this is 5 seconds). If more rays are traced in one call to
    PostArrayTraceMessage than can be traced in the time allowed by DDE_TIMEOUT, an error will occur, and
    PostArrayTraceMessage will return -1. If the ray trace is successful, PostArrayTraceMessage will return 0. It is
    good programming practice to trace rays in small groups of 1000-5000 rays at a time. Once this many rays are
    traced, the overhead of multiple calls using PostArrayTraceMessage becomes negligible. Alternatively,
    DDE_TIMEOUT can be set at a higher number, but this is not preferred.
    are you considering that already?
    hope it helps
    Indranil Sinharoy
    @indranilsinharoy
    Hi @joservargasr, thank you very much for your kind words. Regarding, the multiple ray tracing and timeout issue, PyZDDE doesn't use the zclient.c code to communicate with Zemax. In fact, it directly uses the DDEML library (using ctypes). Also, because PyZDDE uses the DDEML library directly, you can set almost arbitrary values for timeout (although it is not required for all functions). I have described the problem is some detail at http://forum-en.radiantzemax.com/Topic2657.aspx. I think that it is possible to convert the zclient.c using ctypes for multiple ray tracing. However, although I would really love to fix it, right now I don't have any time to spend on it . I hope I will get some time soon, or some one else with the time and need can fix it.
    Regards,
    Juan Antonio Aguilar
    @zemrude
    Hello @indranilsinharoy first of all let me tell you how great PyZDDE is, I've been using it for a couple of months and I could leave without it. I'm far from an expert in Zemax by the python binding really helped me a lot! Now comes the question ;) I have a set of NSC objects in particular 4 CPC where their apertures are linked with pickup variables, so when I change the first one the rest are automatically updated too. However when I do it from python using zSetNSCParameter method it doesn't seem to have the same effect. Is there any caveat or something I might be doing wrong? Thanks a lot
    Indranil Sinharoy
    @indranilsinharoy
    @zemrude Thanks for your kind words! In order to debug, the first thing I would do after setting the pickups is do a zPush(1) to ensure that the solves are set up correctly. If that working as expected, I would then try calling zUpdate() explicitly after changing the aperture of the first one. While writing this message to you I decided to give it a try, and it worked. Here is a link to the screenshot video: https://youtu.be/5rB_XusNn5M (Note that I didn't call zUpdate() in the screenshot video because it is called automatically in the APR mode, which is turned on in an interactive setting by setting ln.apr = True). I hope that helps :smile:
    Indranil Sinharoy
    @indranilsinharoy
    ...however, I noticed a strange thing (and I don't have an explanation right now for why that's happening). In the above toy example that I provided, if you had only 4 NSC objects in the NSC editor (instead of 4 + 1 Null object in the video), I am not able to set NSC solve on the last object. So, be mindful of that.
    Indranil Sinharoy
    @indranilsinharoy
    also I forgot to mention earlier that the APR (automatic push refresh) mode is new that was released in version 2.0.2
    Juan Antonio Aguilar
    @zemrude
    Wow, thanks a lot for all the help... including the video! I will try this out. One I notice seeing your video though, is that when I update parameters/properties from my python notebook, the changes are not reflected in the opened file in Zemax, in other words I cannot see the changes on my Zemax screen, I have to use zGetNSCParameter to see if the change has been made... it's like the file on the Zemax screen remains an exact copy of the opened version and the "python file" continues as a copy. Does it make sense what I say? Thanks a lot again.
    Indranil Sinharoy
    @indranilsinharoy
    Hi @zemrude. You observation is correct. As explained in the l
    Indranil Sinharoy
    @indranilsinharoy
    @zemrude . ooops!! almost all of what I wrote in the last post completely vaporized with a single hit of a key!!! Anyway, I will try to jot down my thoughts again... as explained in here)#brief-description-about-the-communication-process), there are always two independent copies -- one in the DDE server and the other in the main zemax application window (LDE). You can move a lens back and forth using the commands zPushLens() and zGetRefresh(). In the APR mode (as demoed in the video), PyZDDE automatically invokes these commands to make interactivity more easy. Currently, this feature is quite conservative as I am still experimenting with the new feature. You can read more about it here. I hope that helps. Please do let me know if something wasn't clear. Also, please feel free to let me know if you have any suggestions, feedback etc. on improving pyzdde. Thanks. Best regards.
    the first link in the above post got messed up. Here is the full link: https://github.com/indranilsinharoy/PyZDDE/wiki/01.-Getting-started---(get-PyZDDE,-basic-concept,-an-example)
    Juan Antonio Aguilar
    @zemrude
    Thanks a lot @indranilsinharoy, all was very clear. So far, and this is from a a casual user (I'm not really an expert in optical system development but more on high energy physics) I have to say that the overall PyZDDE binding is great and and really an easy way to get started with Zemax. I'll let you know if some suggestions/feedback come along the way. Thanks again
    Indranil Sinharoy
    @indranilsinharoy
    You are welcome, and thank you too for the kind words and possible suggestions/feedback (in future). :smile: Regards.
    mattemilio
    @mattemilio
    Hi,
    mattemilio
    @mattemilio
    Congratulations for the work done! It is really great. I am trying to understand your example file arrayTraceSimple.py. At line 51 and 52 you write rd[k].z = i/(2radius) # px and rd[k].l = j/(2radius) # py but z and l should not be the pupil coordinates. l should be a cosine director of the field. Thanks for your possible help and thanks again for your work. Matteo
    Indranil Sinharoy
    @indranilsinharoy
    @mattemilio Hi, I am sorry. I somehow missed seeing your message. (this channel is usually very silent .... almost like listening out for gravitational waves :smile: ) Anyways, do you still have the question? Plz do let me know. Best regards, Indranil.
    hernandocortes
    @hernandocortes
    Hi
    your pyzdde helped me a lot on developing my software for zemax. do you know how can I properly include it to pyinstaller ? currently i added it to hidden import but it seems the pyinstaller cannot find the settings.ini files
    also Ive notice that the 'Lsh' code for ipzCaptureWindow() is not working
    Indranil Sinharoy
    @indranilsinharoy
    This message was deleted
    Indranil Sinharoy
    @indranilsinharoy
    Hi @hernandocortes . I have not used pyinstaller before. I'm not sure why pyinstaller is looking for "settings.ini". That file is not distributed. Instead, what is distributed is "settings.ini-dist". The "settings.ini" file is generated by PyZDDE the first time it is run. Will this info help? (I'm not sure because I have not used pyinstaller before). Please do let me know either way. Regarding the shaded model code ('Lsh'), what is the error/problem? I don't have the security dongle with me right now, so I couldn't test it. I will do so ASAP and find out the problem. Thanks.
    hernandocortes
    @hernandocortes
    Thanks @indranilsinharoy for your reply. it seems that the problem is with pyinstaller when I include pzydde as hidden import the setting,ini-dist is not copied to bundle. Im trying to compile my software to one exe file. regarding the shaded model, currently im using your ipzCaptureWindow() function and it is very helpful for getting those mtf graphs and laso the 3d Layout ('L3d'). but it seems that when I use the 'Lsh' code ipzCaptureWindow() always return none. even if I adjust the wait time. is there any configuration/setting i must do first?
    Indranil Sinharoy
    @indranilsinharoy
    @hernandocortes . Regarding shaded model. Unfortunately, the reason why ipzCaptureWindow() doesn't work with it is because the "Shaded model" layout window doesn't cannot export the image as a metafile (you can see that the option is grayed out in the window). I am not sure why Zemax doesn't allow exporting the window as metafile. Also, AFAIK unfortunately there are no DDE commands to ask Zemax to export a PNG/BMP version .... and there is another "unfortunately" (I'm sorry), Zemax has completely removed GetMetaFile DDE command from OpticStudio since version 14 ... so ipzCaptureWindow() will not work at all :-( ... is there anyway that you could use ipzCaptureWindowLQ? It does work well enough with OpticStudio (I mean the quality of output). Let me know.
    hernandocortes
    @hernandocortes
    can I use the ipzCatureWindowsLQ? to generate the shade model?
    However, the way the function works is different from ipzCaptureWindow(), because you will need to have that particular window open, and need to know the window number. That function is really a hack. Please check out the description in the above link on how to use the function before you decide to use it. Internally it uses ZPL macro function to capture a screenshot of a particular window. Also check out the function in pyzdde.py to understand better how the function works (and limitations of the function). The good thing is that this function will work even in the newer OpticStudio versions.
    hernandocortes
    @hernandocortes
    I see Thanks a lot!! just want to check with you is this function can be used in zemax 15?
    Indranil Sinharoy
    @indranilsinharoy
    No problem at all. Yes, the function works in zemax 15.
    hernandocortes
    @hernandocortes
    how about the ipzCaptureWindows function? is is still working on ZOS 15 or 15.5 ?Thank you so much for your support!
    Indranil Sinharoy
    @indranilsinharoy
    The ipzCaptureWindow() function internally calls Zmeax with the GetMetaFile DDE dataitem. However, AFAIK Zemax has removed the GetMetaFile DDE dataitem since Zemax 14 (please double check). Therefore, ipzCaptureWindow() will not work in ZOS 15 or 15.5. I feel bad for it too since I use the ipzCaptureWindow() function myself quite often (within the IPython notebook).
    hernandocortes
    @hernandocortes
    I see Thank you @indranilsinharoy !
    pfunk
    @pfunk
    Hi @indranilsinharoy. I'm trying to use your 'arraytrace' module but every time I try to import it I receive the error: "bad magic number in 'pyzdde.arraytrace': b'\x03\xf3\r\n'". If I remove the 'init' compiled-python file from the arraytrace folder then I can import the module and run the demos, but the code can not trace any rays. Any suggestions? I'm running 64-bit python 3.5.2 and Zemax 15.5. Thanks!
    Indranil Sinharoy
    @indranilsinharoy
    @pfunk I'm sorry for responding so late. I haven't been in the chat room. Are you still facing the problem? I will try to find out what's going on.
    pfunk
    @pfunk
    Yep I'm still facing the problem. Thank you very much for looking into it!
    mattjcliffe
    @mattjcliffe
    Haya, does anyone know a nice way for me to read a rectangular detector / or a DDR file in python for easy numpy manipulation
    eseguraca.6
    @eseguraca6
    Hi,
    I am a beginner in ZEMAX, and would like to use the python API
    how can I create an optical setup from scripting rather than modifying existing settings on the zmx file
    TinaWuUW
    @TinaWuUW

    Hi!

    Thank you for publishing this extension. I am wondering if there is a helper function available to grab the ray database viewer information as I cannot seem to find it on the documentation.

    Thank you in advance for your response!

    TinaWuUW
    @TinaWuUW
    If anyone is interested, the ray database viewer can be obtained using the zfileutils class by calling readZRDFile!
    Ke
    @kewang2015_twitter
    I've been using PYZDDE for some time. It's great, very convenient. I am still a beginner. Could someone tell me how I can save the data from an NSC detector into txt file? Thanks.
    TinaWuUW
    @TinaWuUW
    by executing the following function calls, I was able to get the detector viewer file:
    • zPushLens (updates detector with the new setting)
    • zNSCTrace (export the ray tracing DB)
    • set the file name using zSetDetectorViewerSettings
    • zGetDetectorViewer (saves the detector viewer data into text file)
    Maximilian Hoffmann
    @MaximilianHoffmann
    Does anyone know a possibility to match a glass string to a known nd and nud from pyzdde?
    Henrique-Aroeira
    @Henrique-Aroeira
    hey! I've begun using pyzdde recently and I'm loving it!
    But I have an issue: first, I can't find the function(or equivalent) of zDDEBusy from mzdde
    I needed to wait for zemax to finish updating the fft through focus mtf so I could save it and only then push another parameter into the LDE
    Henrique-Aroeira
    @Henrique-Aroeira
    But it is not waiting for the update to end and is pushing new data relentlessly until the loop ends