Skip to main content
Solved

Conversion between integer type and ZOSAPI Enum in MATLAB

  • September 17, 2021
  • 2 replies
  • 145 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.

Best answer by Csilla Timar-Fulep

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

View original
Did this topic help you find an answer to your question?

2 replies

Csilla Timar-Fulep
Zemax Staff
Forum|alt.badge.img+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


  • Author
  • Single Emitter
  • 1 reply
  • September 23, 2021

Hi Csilla,

  That worked great.  Thank you very much.

Cheers,

Jason


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