mjhoptics / ray-optics

geometric ray tracing for optical systems
BSD 3-Clause "New" or "Revised" License
263 stars 54 forks source link

Filenames in the zemax module need to be pathlib paths (and this is not documented) #26

Closed InfraRedOx closed 3 years ago

InfraRedOx commented 3 years ago

Hi there, I noticed that when trying to use functions from the zemax module (such as read_lens_file), supplying a path as a string will not work, as the first input argument filename is expected to have the methods found in a pathlib Path object (such as "open") This doesn't seem to be documented.

The fix seems to be to use such a syntax:

filepath = pathlib.Path("subdir/myfile.zmx') rayoptics.zemax.zmxread.read_lens_file(filepath)

Would it be possible to update the docs to reflect this, or alternatively to enable paths supplied as string objects?

mjhoptics commented 3 years ago

Hello @InfraRedOx, I would recommend using the open_model() function, that is imported from gui.appcmds by environments.py. This will accept strings or filepaths for opening any supported file type (currently Zemax, CODE V, and the native .roa files). I'll update the documentation on read_lens_file to be more specific.