How to load BSDF File in scatter model of object properties in ZOS API Matlab and Python

  • 24 February 2022
  • 0 replies
  • 171 views

Userlevel 4
Badge +1

In OpticStudio, We can load any BSDF file from our   \Zemax\ScatterData Folder .Here is the available code for Matlab and Python. You can use this code in Standalone or Interactive Extension.

-Copy the code in your file .

-Change the path of testfile

Matlab Code: 

TheNCE = TheSystem.NCE; 

Object_2 = TheNCE.GetObjectAt(2); 

% changes scatter profile on face 

Scatter_Data=Object_2.CoatScatterData.GetFaceData(0);

o3_Scatter = Scatter_Data.CreateScatterModelSettings(ZOSAPI.Editors.NCE.ObjectScatteringTypes.BSDF);      

o3_Scatter.S_BSDF_.ReflectFile  = 'BrownVinyl.bsdf'; 

o3_Scatter.S_BSDF_.TransmitFile = 'BrownVinyl_HighRes.bsdf'; 

o3_Scatter.S_BSDF_.ScatterFraction = 0.775; 

 o3_Scatter.S_BSDF_.Angle = 30; 

 Object_2.CoatScatterData.GetFaceData(0).ChangeScatterModelSettings(o3_Scatter); 

 Object_2.CoatScatterData.GetFaceData(0).NumberOfRays = 2;

 

Python code :

testFile = r"C:\test\Digital_projector_flys_eye_homogenizer.zos"

TheSystem.LoadFile(testFile, False)

print(TheSystem.SystemFile)

TheNCE = TheSystem.NCE

Object_3 = TheNCE.GetObjectAt(5)

Scatter_Data=Object_3.CoatScatterData.GetFaceData(0)

ScatType_Lam = Scatter_Data.CreateScatterModelSettings(ZOSAPI.Editors.NCE.ObjectScatteringTypes.BSDF)

ScatType_Lam._S_BSDF.ReflectFile = 'BrownVinyl.bsdf'

ScatType_Lam._S_BSDF.TransmitFile ="BrownVinyl_HighRes.bsdf"

ScatType_Lam._S_BSDF.ScatterFraction = 1

Object_3.CoatScatterData.GetFaceData(0).ChangeScatterModelSettings(ScatType_Lam)

Object_3.CoatScatterData.GetFaceData(0).NumberOfRays = 1

 


0 replies

Be the first to reply!

Reply