Skip to main content
Question

Application.NumberOfOpticalSystems is 0 when connecting in extension mode


chaasjes
Forum|alt.badge.img

While running the unit tests for ZOSPy, I discovered that calling Application.GetSystemAt(0) throws a System.ArgumentOutOfRangeException . This is rather weird, since the primary system should always be present. Upon further inspection, Application.NumberOfOpticalSystems turned out to be 0.

I tried to reproduce this problem in C#, and succeeded. The problem also occurs in this example:

bool isInitialized = ZOSAPI_Initializer.Initialize();
var connection = new ZOSAPI_Connection();
var application = connection.ConnectAsExtension(0);

Console.WriteLine(application.NumberOfOpticalSystems); // --> 0

var systemZero = application.GetSystemAt(0); // --> Throws ArgumentOutOfRangeException

But not in this one, while the new surface added at the end doesn't appear in the GUI (indicating it is not interacting with the primary system):

bool isInitialized = ZOSAPI_Initializer.Initialize();
var connection = new ZOSAPI_Connection();
var application = connection.ConnectAsExtension(0);

Console.WriteLine(application.NumberOfOpticalSystems); // --> 0

application.CreateNewSystem(SystemType.Sequential);

Console.WriteLine(application.NumberOfOpticalSystems); // --> 1

var systemZero = application.GetSystemAt(0); // Returns a system

systemZero.LDE.InsertNewSurfaceAt(2).Comment = "New surface"; // Nothing happens in the primary system

If I connect in standalone mode instead of extension mode, the number of optical systems is equal to 1 and I can connect to the optical system at position 0.

I would expect the number of optical systems to be 1 in extension mode as well. Is the observed behaviour correct, or is it a bug in the ZOS-API?

Additional information

OpticStudio version: 23 R1.00
Windows 10 Enterprise, Build 19044

 

0 replies

Be the first to reply!

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