xzos / PyZDDE

Zemax/ OpticStudio Extension using Python
MIT License
155 stars 64 forks source link

Kernel busy when running "link.ipzCaptureWindow2('Lay',gamma=0.25)" #1

Closed imyu37 closed 11 years ago

imyu37 commented 11 years ago

These days i found pyZDDE in github and tried to verify it. It ran OK except for the code line "link.ipzCaptureWindow2('Lay',gamma=0.25)".The ipython notebook was dead with indicating Kernel busy in the upper right. I don't know what's happening.

indranilsinharoy commented 11 years ago

@imyu37 Hi, normally it takes a little time for this command to complete as it basically requests ZEMAX to dump the 2D layout as enhanced metafile, and then use ImageMagick to downsample and convert to PNG image and then use ipython's display function to eventually embed the png into the notebook. I have seen that the conversion process can take a little while, especially depending on the machine. During all this time the notebook is expected to indicate "Kernel busy" and that is a normal thing. However, it has never crashed/died during my test and usage. (although few times it just fails to embed and image, because ZEMAX wouldn't dump an image). If it can't do the job, within certain time, the function should just timeout and return with a text message indicating so. While I will try to do some more test to check this out, can you please let me know what version of IPython and ZEMAX you are using?

Thank you. Regards, Indranil.

indranilsinharoy commented 11 years ago

@imyu37 Also, can you check if "32 Bit Enhanced" is the option selected for Metafiles under Preferences->Graphics menu? If not, please select that option as ZEMAX doesn't seem to dump any of the other graphic windows if 16 Bit Standard is selected.

imyu37 commented 11 years ago

@indranilsinharoy "32 Bit Enhanced" is surely checked. The version of ipython and ZEMAX are 0.13.2 , November 10 2008,respectively. And the Python version is 2.75.

indranilsinharoy commented 11 years ago

@imyu37 Thank you very much for the information. I have been using Zemax 13 (2013 version). I think I might be able to get my hands to an older copy of Zemax. I will run it on the older version and see what's wrong. I will get back to you soon with my findings. Thanks a lot again for using the tool and reporting the issue.

indranilsinharoy commented 11 years ago

Hi @imyu37, The problem should be fixed now (I could get my hands to a 2005 version of ZEMAX). Here is a description of the problem:

The function ipzCaptureWindow2() was using the default lens path for extracting, processing and then deleting the temporary metafile. However, in earlier versions of ZEMAX (sometimes prior to approx. 2009) this path is in C:\Program Files\Zemax\Samples. Accessing this folder is likely not work due to permission issues. After the fix, this function is going to use the directory of the lens file (not the default lens path as set in the preferences of Zemax).

You can either download the latest code with the fix in place or make the change yourself in the file PyZDDE/pyzdde/zdde.py by changing the line tmpImgPath = self.zGetPath()[1] (line # 6007) to tmpImgPath = path.dirname(self.zGetFile())

It will be really very kind of you if you could please let me know if that fix worked for you. Once I hear back from you (which I hope will be positive :-)), I will close this issue.

Thank you very much once again, and I hope you will keep using PyZDDE.

imyu37 commented 11 years ago

@indranilsinharoy After your fixing, the demo code in /PyZDDE /Doc/Images runs correctly now.

indranilsinharoy commented 11 years ago

Hi @imyu37 Thanks very much for verifying. I will close this issue.