Skip to main content

In opticStudio ,we can set User defined surface through Python and Matlab program using standalone and Interactive Extension.

-Set the user defined surface 

-Select the User defined surface from directory

-Get the User defined surface

Matlab Code:

You can directly copy the code in Standalone or Interactive Extension:

   import ZOSAPI.*;

    % Set up primary optical system

    TheSystem = TheApplication.PrimarySystem;

    sampleDir = TheApplication.SamplesDir;

    testFile = System.String.Concat('C:\test\ABCD\ABCD Simple_lens.zmx');

    TheSystem.LoadFile(testFile, false);

    TheLDE = TheSystem.LDE;

    surf2 = TheLDE.GetSurfaceAt(2);

    typeSettings = surf2.GetSurfaceTypeSettings(ZOSAPI.Editors.LDE.SurfaceType.UserDefined);

    filesAvailable = typeSettings.GetFileNames();

    typeSettings.Filename = filesAvailable(5);

    surf2.ChangeType(typeSettings);

    d=typeSettings.Filename;

    disp(d)

 

Interactive Extension Matlab 

Python  Code:

You can directly copy the code in Standalone or Interactive Extension:

# Insert Code Here

testFile =r"C:\Double Gauss 28 degree field.zmx"

TheSystem.LoadFile(testFile,False)

test = str(TheSystem.GetCurrentStatus())

print(test)

TheLDE = TheSystem.LDE;

surf2 = TheLDE.GetSurfaceAt(1);

typeSettings = surf2.GetSurfaceTypeSettings(ZOSAPI.Editors.LDE.SurfaceType.UserDefined);

filesAvailable = typeSettings.GetFileNames();

typeSettings.Filename = filesAvailable(5);

surf2.ChangeType(typeSettings);

print(typeSettings.Filename)

Interactive Extension Python

Download

Be the first to reply!

Reply