Hello! I’m trying to run batch ray traces from Python and have encountered some difficulties. Originally I didn’t use this feature because it was quite slow - since each ray needed to be traced individually in a for loop. But after discovering this Knowledgebase article: Batch Processing of Ray Trace Data using ZOS-API in MATLAB or Python – Knowledgebase (zemax.com) I got excited to try the new Raytrace DLL.
|
I started by getting the MATLAB example file working, which was pretty trivial. It basically ran as soon as I downloaded it.
However, I need the raytracing to be done in Python - so I tried to translate from the MATLAB example file, which did not work very well. First I encountered this error:
- module ‘clr’ has no attribute ‘AddReference’
Which I fixed by uninstalling clr and installing pythonnet (woops, that’s on me). I had to downgrade to Python3.8 to install pythonnet. The next error I encountered after I finally got the code running seems more fundamental, when trying to run NET.addAssembly(pwd+’\Raytrace.dll’) it says
- NameError: name ‘NET’ is not defined.
Where is NET supposed to be imported? I don’t see it explicitly earlier in the script, or the accompanying script “PythonNET_ZRDLoaderFull.py”.
Alternatively, if someone could just point me to an example of sequential raytracing using the Raytrace.dll that would be very helpful.
Thanks!