Skip to main content

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

  • February 24, 2022
  • 0 replies
  • 206 views

Sahil
Forum|alt.badge.img+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

 

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

0 replies

Be the first to 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