xzos / PyZDDE

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

Read/Write ZRD Files #42

Closed olfduh closed 9 years ago

olfduh commented 9 years ago

Hi,

I started to implement some functions to read and write zrd files. So far I created a class for Zemax rays and a function to read the file. My plan is to have a separate file for the ray class ind import it to the zdde.py file where I would add the read/write functions. I'll upload it to my fork soon and send you a pull request. If you have any better idea how to implement the functions, please let me know!

Could it be possible to do the bulk ray tracing by creating a ray file from Python and import this to Zemax? Might be a temporary solution for this problem...

Best,

Olf

indranilsinharoy commented 9 years ago

Hi olf,

That is great.

"If you have any better idea how to implement the functions, please let me know!"

Sounds good to me. Once I see your branch, may be, we can exchange ideas regarding that.

"Could it be possible to do the bulk ray tracing by creating a ray file from Python and import this to Zemax? Might be a temporary solution for this problem..."

Unfortunately, I don't know. Why don't you give it a try? (I have been a little busy lately with my PhD, and I don't have much bandwidth to work on this problem myself right now, although I really wish to solve the bulk ray tracing problem). So, all ideas are welcome.

Regards, Indranil.

olfduh commented 9 years ago

How far did you get with the bulk ray tracing? What was the problem? I am quite interested in this feature, so if I know some more details, I can give it a try :) Do you have an example how to trace single rays? From your documentation I get that this should be possible but didn't get it to work yet...

Edit: I had a look at the MZDDE Package. The way to go for the bulk ray tracing could be to use the c++ file from the MZDDE and change all the Matlab specific parts to Python. The Python wrapper can be created with SWIG. I have to admit I never did this before and also only have very limited time to work on it...

indranilsinharoy commented 9 years ago

Hi olf,

I tried to work on this sometime last year, using ctypes-based-DDEML to communicate (poke messages), but couldn't get it working. I suspect that it has something to do with how Zemax is internally handling the poke messages. Here is what I found: http://forum.zemax.com/Topic2657.aspx.

"Do you have an example how to trace single rays?"

Well, we can do single ray tracing ... using zGetTrace() and zGetTraceDirect() ... not sure if that's what you were asking. But I just wanted make sure that we are on the same page. If you are asking about single ray tracing using the same strategy of bulk ray tracing, then I am afraid, I haven't succeeded.

I agree with the strategy that you have suggested. In fact I have a piece of code from Ian Rousseau who was able to do bulk ray tracing using this strategy (used ctypes instead of SWIG). Right now I don't have the bandwidth to understand and fully integrate his solution into PyZDDE. However, he has been kind enough to send me his code, and I have his permission to give his code to interested folks. Let me know (send me an email) if you would like to take a look at his code.

olfduh commented 9 years ago

Hi, I was a bit stupid on about tracing single rays it was really easy :)

indranilsinharoy commented 9 years ago

Hi Olf,

No problem at all.

indranilsinharoy commented 9 years ago

Closing this issue as the appropriate functions has been added to PyZDDE from https://github.com/indranilsinharoy/PyZDDE/pull/43