Solved

Why I got the message Failed to locate OpticStudio when trying to run an extension

  • 19 September 2023
  • 4 replies
  • 205 views

Userlevel 5
Badge +3

 

 

 

icon

Best answer by yuan.chen 19 September 2023, 03:56

View original

4 replies

Userlevel 5
Badge +3

The issue may be related to an incorrect OpticStudio executable path found within the code.
?name=image.png
When using the API to perform user analysis or other modes, the first step is to locate the installation folder of OpticStudio. If multiple versions of OpticStudio are installed, the determination condition may not be met. This can result in isInitialized returning false and displaying an error message. Reinstalling OpticStudio may often resolve this issue. Since I have not encountered any problems with version 2023 R2, I suggest trying the following two methods:
 

Method1:

First, close all OpticStudio files, including those in use by third-party programs running in the background, such as Matlab, Python, or Visual Studio.
Then, locate the file named "version.log" under the folder C:\Users\...\Documents\Zemax\License and delete it.
?name=image.png
Open Ansys Zemax OpticStudio, and it will automatically update the contents under the Zemax Data folder(including the ZOSAPI_NetHelper.dll). Ensure that the process is not interrupted and avoid any files within the Zemax Data folder that are currently in use. Then open OpticStudio, and try the user extension.
?name=image.png
 This is what I got after trying method 1.
?name=image.png

Method2: 

 
Close all OpticStudio files, including those in use by third-party programs running in the background, such as Matlab, Python, or Visual Studio.
Reinstall the latest version of OpticsStudio. 

Userlevel 6
Badge +2

Hi @yuan.chen,

There are a few more reasons why this could fail (such as “Prefer 32-bit” when the Platform Target is Any CPU, using a VM with a UNC path for the User Extension, or uninstalling an old version of ZOS after installing the current version).  All these issues stem from a failure to locate the OpticStudio.exe (and more importantly, the ZOSAPI.dll ZOSAPI_Interfaces.dll in the same folder) and this is directly due to the ZOSAPI_NetHelper.dll.

I opened a case (#59566) in March of 2023 with a patch to solve this issue.  It was closed as “not needed” but if you have to create a post about this issue, I think you should look at this case and potentially reopen/implement the solution.  

Userlevel 5
Badge +3

Hi Michael, many thanks for letting me know this! I am discussing internally to see what we can do. Really appreciate your help!

Hi @yuan.chen,

There are a few more reasons why this could fail (such as “Prefer 32-bit” when the Platform Target is Any CPU, using a VM with a UNC path for the User Extension, or uninstalling an old version of ZOS after installing the current version).  All these issues stem from a failure to locate the OpticStudio.exe (and more importantly, the ZOSAPI.dll ZOSAPI_Interfaces.dll in the same folder) and this is directly due to the ZOSAPI_NetHelper.dll.

I opened a case (#59566) in March of 2023 with a patch to solve this issue.  It was closed as “not needed” but if you have to create a post about this issue, I think you should look at this case and potentially reopen/implement the solution.  

Dear Michael,

Your information is helpful! What will be the fix in the case of “uninstalling an old version of ZOS after installing the current version” besides reinstalling OpticStudio?

Regards,

Jiang

Reply