Skip to main content

Hello,

I was trying to set the material model properties through Python API but it did not work. The result I get is implementation of material model to my Zemax modelm but with the refractive index of 0. Could you help me with this?

Thank you in advance! 

The code I use is visible below:

materialModel = surface.MaterialCell.CreateSolveType(ZOSAPI.Editors.SolveType.MaterialModel)

materialModel.IndexNd = 1.33

materialModel.AbbeVd = 5

surface.MaterialCell.SetSolveData(materialModel)

Best wishes,

Fabian

Hi @fabian358,

You need to use the _S_MaterialModel property of the SolveData object:

materialModel = surface.MaterialCell.CreateSolveType(ZOSAPI.Editors.SolveType.MaterialModel)._S_MaterialModel
materialModel.IndexNd = 1.33
materialModel.AbbeVd = 5
surface.MaterialCell.SetSolveData(materialModel)

If you want an easier way to set the material model (and other solve types), you can check out ZOSPy, which reduces this to a single function call:

import zospy as zp

...

zp.solvers.material_model(
surface.MaterialCell,
refractive_index=1.33,
abbe_number=5
)

 


Reply