Solved

Conversion between integer type and ZOSAPI Enum in MATLAB

  • 17 September 2021
  • 2 replies
  • 117 views

I’d like to programmatically adjust the value of a Parameter cell in the Non-Sequential Editor, something like:

TheSystem.NCE.GetObjectAt(obj_num).GetObjectCell(cell_num).DoubleValue = value;

However, GetObjectCell only takes a ObjectColumn enum as an argument, and the ObjectColumn enum does not seem to accept assignment from an integer.  I can write a lengthy switch block that returns the appropriate ObjectColumn enum based on an integer input, but that seems like an ugly solution, when (according to the manual), the enum value for the Parameter columns is the parameter number plus 10, i.e. the following should work:

TheSystem.NCE.GetObjectAt(obj_num).GetObjectCell(param_num + 10).DoubleValue = value;

However, this generates an error.  I tried using cast, e.g.

param_col = cast(param_num + 10, ‘ZOSAPI.Editiors.NCE.ObjectColumn’);

but this generates an error.

Any suggestions appreciated.

icon

Best answer by Csilla Timar-Fulep 21 September 2021, 14:58

View original

2 replies

Userlevel 5
Badge +2

Hi Jason,

Thanks for posting on the Community forums!

For this purpose, you can use the GetCellAt() member function of the ZOSAPI.Editors.IEditorRow Interface Reference: 

The GetCellAt() function takes an integer input, and indeed as you said the integer input value for the Parameter columns is the parameter number plus 10.

You may use the following line in MATLAB:

TheSystem.NCE.GetObjectAt(obj_num).GetCellAt(param_num + 10).DoubleValue = value;

I hope this helps, but if you need any further assistance, please do not hesitate to ask.

Best,
Csilla

Hi Csilla,

  That worked great.  Thank you very much.

Cheers,

Jason

Reply