xzos / PyZDDE

Zemax/ OpticStudio Extension using Python
MIT License
159 stars 67 forks source link

``ipzCaptureWindow()`` function doesn't work in Windows 8 machine #34

Closed indranilsinharoy closed 10 years ago

indranilsinharoy commented 10 years ago

The function call to ipzCaptureWindow() times out with the message "Timeout reached before PNG file was ready", and doesn't embed the desired graphic into an IPython console/notebook. Examining a bit further, it seems that the root cause of this problem is that ImageMagick's convert.exe is unable to convert the EMF into PNG file because "VCOMP100.DLL" is missing from the computer (System Error message).

indranilsinharoy commented 10 years ago

Upon some close inspection, it seems that there are several aspects to this particular problem. I think it would be a good idea to document what I have found till now here, for future reference. They are the following:

  1. For some reason, the dll "VOCOMP100.DLL" wasn't present (at least in my windows 8.1 machine). This can be (possibly) resolved by installing BOTH Visual C++ 2010 Redistributable Package (x86) and Visual C++ 2010 Redistributable Package (x64), as recommended here.
  2. Again, for some reason (I am not sure of) the size of the Windows Metafile (EMF) exported by Zemax in my Windows 8.1 machine is much larger (10,884 x 8,179 pixels) than the EMF files exported by Zemax (3,630 x 2,722 pixels) in my Windows 7 machine (with the same version of Zemax, and same Graphic settings). So, the blur and flatten while converting from EMF to PNG using ImageMagick's "convert" command takes painfully long time.
  3. I also decided to try another option --- install ImageMagick in my Windows 8.1 and use subprocess.Popen() to call convert (of course without using blurring and flatten options). It turns out that the "convert" command of ImageMagick conflicts with a Windows command of the same name, as documented here. I think a reasonable way to circumvent this problem is to provide full path to ImageMagick's convert command while calling subprocess.Popen().

One solution could be the following:

Use a settings (possibly the existing settings file) to store options/preference about which convert to use --- convert from an installed version of ImageMagic or the convert.exe that comes along with PyZDDE. Also, the settings file will store information about whether to skip blurring and flattening, if the zCaptureWindow() function takes too long to complete or times out.

indranilsinharoy commented 10 years ago

Fixed in commit https://github.com/indranilsinharoy/PyZDDE/commit/f861261b12c5d370fac06aea8c45972e0b23e82f