Question

can I import an excel table as merit function?

  • 5 December 2023
  • 2 replies
  • 35 views

I want to create a long merit function with large number of duplicated operand and the input values are results from some formula operation. Can I create the merit function in excel and then copy or import it to the ZEMAX?

Or is there a ZPL commend to use to insert operand into a MF?

 

Thanks very much.


2 replies

Userlevel 3
Badge +1

You can copy an excel table into the merit function editor, but it's not very convenient if the merit function is long. This is one area I think the OpticStudio editors could be improved. When copying a m x n array of cells from excel, you need to highlight the same m x n cells in the zemax editor in order for all of the cells to be pasted. So in your case, you would need to have an equal number of merit function operands already inserted into the merit function editor as you have operands in the excel file. Then you need to highlight all of the rows in the merit function editor, right click, and choose “Paste Cells”. 

It would be simpler to copy the excel data into a txt file and save it with the .MF extension. Then you can load all of the operands into the merit function editor. 

There is a ZPL keyword INSERTMFO to insert an operand into the merit function. Use this in combination with SETOPERAND to define your merit function with a ZPL script.

Hi Sean,

Thanks  a lot for these helpful hints. That is exactly what I needed.

 

Reply