I wrote that code according to section #! [e21s03_py] in example 21 of the ZOS-API Python examples
Apparently, the code does not work.
Did anyone ever manage to exchange source files via python?
Can you provide a code snippet that works?
Thanks in advance
Best answer by chaasjes
Hi @dsotm,
Thank you for asking this question and nice to see you’re using ZOSPy! I checked the example code and this works for me:
import zospy as zp
zos = zp.ZOS() oss = zos.connect("extension")
oss.new() oss.make_nonsequential()
# Add new catalog MISC oss.SystemData.MaterialCatalogs.AddCatalog('MISC') # Set Wave #1 to 0.47 micron oss.SystemData.Wavelengths.GetWavelength(1).Wavelength = 0.47 # Use lumens as the source unit oss.SystemData.Units.SourceUnits = zp.constants.SystemData.ZemaxSourceUnits.Lumens # ZOSAPI.SystemData.ZemaxSourceUnits.Lumens #! [e21s01_py]
Thank you for asking this question and nice to see you’re using ZOSPy! I checked the example code and this works for me:
import zospy as zp
zos = zp.ZOS() oss = zos.connect("extension")
oss.new() oss.make_nonsequential()
# Add new catalog MISC oss.SystemData.MaterialCatalogs.AddCatalog('MISC') # Set Wave #1 to 0.47 micron oss.SystemData.Wavelengths.GetWavelength(1).Wavelength = 0.47 # Use lumens as the source unit oss.SystemData.Units.SourceUnits = zp.constants.SystemData.ZemaxSourceUnits.Lumens # ZOSAPI.SystemData.ZemaxSourceUnits.Lumens #! [e21s01_py]