Skip to main content
Solved

MATLAB reload zemax file


Nils.Melchert

Hello,

I was wondering, if there is a ways using the API to reload the zemax file to its default.

Every single time, I am using the API, I need to start a new instance of OpticStudio. However, it would be nice, to simply reload the file, that I am working on, in order to save some time.

 

Is there a way to do something like this?

 

Best answer by David.Nguyen

Hi Nils,

 

I’m not sure that’s what you meant, but you can save your file right after starting the API:

TheSystem.SaveAs(path)

And then once you want to reset your file, just load it again:

TheSystem.LoadFile(path, false)

Be wary that the second parameter of the LoadFile method is set to false, it corresponds to the saveIfNeeded flag. If this flag is set to true, it saves your file before loading the new file (hence overwritting it).

Let me know if that answers your question.

Take care,

 

David

View original
Did this topic help you find an answer to your question?

2 replies

David.Nguyen
Luminary
Forum|alt.badge.img+2
  • Luminary
  • 1112 replies
  • Answer
  • October 6, 2021

Hi Nils,

 

I’m not sure that’s what you meant, but you can save your file right after starting the API:

TheSystem.SaveAs(path)

And then once you want to reset your file, just load it again:

TheSystem.LoadFile(path, false)

Be wary that the second parameter of the LoadFile method is set to false, it corresponds to the saveIfNeeded flag. If this flag is set to true, it saves your file before loading the new file (hence overwritting it).

Let me know if that answers your question.

Take care,

 

David


Nils.Melchert
  • Author
  • Infrared
  • 14 replies
  • October 6, 2021

Thank you! That was exactly, what I was looking for.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings