Home Forums GENERAL Issue with MATLAB Code Accessing OptiSystem 22 Subsystem Canvas

Viewing 1 reply thread
  • Author
    Posts
    • #89287
      Jaime Romero Huedo
      Participant

      Hello,

      I have been working with a MATLAB script that successfully opened OptiSystem, accessed its document layout and canvas, and also retrieved a subsystem’s component along with its internal canvas.

      With OptiSystem version 21, this code worked without any issues. However, after upgrading to version 22, I am now encountering an error.

      Here is my MATLAB code:

      % Create a COM server running OptiSystem
      optsys = actxserver(‘optisystem.application’);

      % Section looks for OptiSystem process and waits for it to start
      %%%%%%%%%%%%%%%%%%%%%%%%%%%%
      % Execute the system command
      taskToLookFor = ‘OptiSystemx64.exe’;
      % Now make up the command line with the proper argument
      % that will find only the process we are looking for.
      commandLine = sprintf(‘tasklist /FI “IMAGENAME eq %s”‘, taskToLookFor);
      % Now execute that command line and accept the result into “result”.
      [status, result] = system(commandLine);
      % Look for our program’s name in the result variable.
      itIsRunning = strfind(lower(result), lower(taskToLookFor));
      while isempty(itIsRunning)
      [status, result] = system(commandLine);
      itIsRunning = strfind(lower(result), lower(taskToLookFor));
      end
      %%%%%%%%%%%%%%%%%%%%%%%%%%%%

      % Open the OptiSystem file defined by the path
      directory = strcat(pwd,’\PRUEBA_canva.osd’);
      optsys.Open(directory);

      Document = optsys.GetActiveDocument;
      LayoutMngr = Document.GetLayoutMgr;
      CurrentLyt = LayoutMngr.GetCurrentLayout;
      Canvas = CurrentLyt.GetCurrentCanvas;

      % Here I retrieve the object, which is a subsystem
      TransmiterCanvas = Canvas.GetComponentByName(‘TRANSMITER’);

      % However, when I try to get its canvas to access its internal components, I get this error:
      Canvas2 = TransmiterCanvas.GetCanvas;

      Error Message:
      Error using Interface.F1099F9F_9EE0_4649_899E_EBCF6BDB358A/GetCanvas
      Error: The server threw an exception.

      Error in SIMULACIONES_PM_con_ED (line 34)
      Canvas2 = TransmiterCanvas.GetCanvas;

      As I mentioned, this exact same code worked perfectly in the previous version (21), but now with version 22, it no longer works.

      I would like to understand what has changed in version 22 that is causing this issue. Is there a new way to access the canvas of a subsystem in the updated API?

      Thank you for your help.

    • #89302
      Scott Newman
      Moderator

      Hello Jaime,

      I have setup a test design file in OptiSystem and have tested it with your copied Matlab code. The script runs without error and I am unable to reproduce your error. If you could send an email to support@optiwave.com with the following information we will try to see if we can identify the issue:

      • Are you using a paid version of the product or using the 30-day evaluation? If a paid version can you please provide your license number.
      • Windows OS version – 10 or 11?
      • Full version number of OptiSystem can be obtained from the “About OptiSystem” option under the “Help” menu. I am looking for something like 22.0..0.3239
      • The “.osd” file you are using along with the matlab snippet.

      Thanks,
      Scott

Viewing 1 reply thread
  • You must be logged in to reply to this topic.