Skip to main content

Hi,



The Attach Files is my problem.



Why i can't Connect to ZEMAX with microsoft excel .



Can you teach me how to Connect to ZEMAX.



Thank you!

problem.png

Hi Shen-Bo,



I don't t think you can connect to OpticStudio with Excel. You will need to create a standalone mode instead.



I have attached an example that you can try. Let me know if it works.



Sandrine


HI Sandrine,



This example is create a new one zemax file.



I want to get data from zemax with excel to analysis.



Is have the method to connect to my old  zemax file ?



Thank you


Hi Sheng-BO,



When you're using the ZOS-API with Excel, all of the API-specific commands will be open to you! This includes the commands LoadFile and LoadNewSystem. Each of these commands will allow you to load an already-generated lens file into Excel. I am attaching a quick example of how we can open a file and extract some data. 



In this example, you will see that the sample file Cooke 40 degree field.zmx is opened. This sample file is available in your {Zemax}\Samples directory. From there, the example will extract the Radius of surface 3 and print it to the first cell in the Excel workbook:



 





 



For printing to Excel, those commands are specific to that program. In my case, I hard-coded the output to a specific cell, but there are certainly other methods to write data to Excel as discussed here: https://analysistabs.com/excel-vba/write-data-to-worksheet-cell/.



For API-specific commands - these are almost always the same across programming languages. Take a look at the Knowledgebase article 'Sample code for ZOS-API users' for some examples, and the article 'Navigating the ZOS-API Syntax Help Document' for a guide on how to find the commands you need!



Let us know if you have any other questions about this. And have a great week!



Best,



Allie


Thank you


Reply