xzos / PyZDDE

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

Bug fixes #91

Closed LucVV closed 5 years ago

LucVV commented 5 years ago

Hi Indranil,

I've made some changes to the code, as I ran into some bugs. These changes include:

1): Fixed the possibility to create a connection to a random DDE server by a sequential use of ln = pyz.PyZDDE(); ln.zDDEInit(); ln.zDDEClose(). The random DDE server returned None on a DDE command, which crashed the code. I added two checks to circumvent this, one by assessing the validity of the server upon connection (the hszServName is None in this occurance) , and a second one that checks the number of live connections before assigning the DDE sever name.

2): In my current version of Zemax (18.4), the zSetField() function does not return the expected values (as expected by the zDDE code, which matches the returns as stated in the manual). Instead, it returns the values that you would expect from zSetWave()/zGetWave(). The main goal of the command, setting a field value, still works. To solve this issue, I rewrote the function to first assess the number of returned values, and, if this is 2 (with the bug) in stead of 8 (as expected), it calls zGetField() (which works fine).

Could you evaluate these changes?

Regards,

Luc