Skip to main content
Solved

How to change a value on Ray Rotator via MATLAB

  • June 18, 2021
  • 1 reply
  • 63 views

Hi, 

Something strange has happened. I had previously a code that worked and now it doesn't (I have updated ZEMAX since then). 

The code I am having issues with, is changing an angle to 'Ray Rotator' in Par 3 or Par 4 (column 3 or 4 from Material on the editor list), which in this case is the angle of the rotationZ and rotationY. The problem is that I am getting error message: 

Unable to use a value of type ZOSAPI.Editors.NCE.ObjectColumn as an index.

Error in GetAngle_Cond3_v2>writeTiltAboutY (line 142)
        NCEObj.GetObjectCell(ZOSAPI.Editors.NCE.ObjectColumn.Par4).DoubleValue = y;

Error in GetAngle_Cond3_v2>BeginApplication (line 70)
        writeTiltAboutY(o23, angleY);

Error in GetAngle_Cond3_v2 (line 14)
        r = BeginApplication(TheApplication, args);

 My code is: 

  o23 = TheNCE.GetObjectAt(14);
        % Set the Tilt Angle of Y
        writeTiltAboutY(o23, angleY);
    function writeTiltAboutY(NCEObj, y)
        NCEObj.GetObjectCell(ZOSAPI.Editors.NCE.ObjectColumn.Par3).DoubleValue = y;
    end

I have no idea what that means.
Any ideas how to change the angle from matlab in the editor,

NCEObj.GetObjectCell(ZOSAPI.Editors.NCE.ObjectColumn.Par3).DoubleValue = y?

doesn't seem to be working. I also tried

NCEObj.RotateY = y,

but its not doing what I want. Nothing seem to be happening.
I also tried 

o23.GetObjectCell(ZOSAPI.Editors.NCE.ObjectColumn.Par3).IntegerValue = angleY

The row values are correct according to the editor list.
Its a non-sequential analysis.

Looking further I can see that, 023 is empty [], even though i write:  

o23 = TheNCE.GetObjectAt(14);  

TheNCE is however containing something. 

TheNCE = 

  ZOSAPI_NCE with properties:

    AllObjectsTypeSource: [1×1 System.Collections.Generic.List>]
             EveryObject: [1×1 System.Collections.Generic.List]
              AllSources: [1×1 System.Collections.Generic.List]
            AllDetectors: [1×1 System.Collections.Generic.List]
              AllObjects: [1×1 System.Collections.Generic.List]
       RowToObjectOffset: 1
           ActiveSurface: 1
         NumberOfObjects: 1
             FirstColumn: Comment
              LastColumn: Par250
                    Type: NonSequentialComponents
               MinColumn: 1
               MaxColumn: 260
            NumberOfRows: 1
                  Editor: NCE
                  Parent: [1×1 ZemaxUI.ZOSAPI.ZemaxSystem]

Any ideas?

Thanks for any assistance!

Best answer by David.Nguyen

Hi Susan,

This probably won't help you, but in a Python Interactive Extension with the latest update of OS, the following code works for me:

MyRayRotator = TheSystem.NCE.GetObjectAt(2)
MyRayRotator.GetObjectCell(ZOSAPI.Editors.NCE.ObjectColumn.Par3).DoubleValue = 5.3

I have a Ray Rotator in line 2 of my NCE, and its value gets updated to 5.3.

I don't own a MATLAB licence to test, but can you share more of your code for troubleshooting?

Take care,

David

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

1 reply

David.Nguyen
Luminary
Forum|alt.badge.img+2
  • Luminary
  • 1098 replies
  • Answer
  • June 22, 2021

Hi Susan,

This probably won't help you, but in a Python Interactive Extension with the latest update of OS, the following code works for me:

MyRayRotator = TheSystem.NCE.GetObjectAt(2)
MyRayRotator.GetObjectCell(ZOSAPI.Editors.NCE.ObjectColumn.Par3).DoubleValue = 5.3

I have a Ray Rotator in line 2 of my NCE, and its value gets updated to 5.3.

I don't own a MATLAB licence to test, but can you share more of your code for troubleshooting?

Take care,

David


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