In OpticStudio, We can load any spectrum file from our \Objects\Sources\Spectrum Files 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:
import ZOSAPI.*;
TheSystem = TheApplication.PrimarySystem;
sampleDir = TheApplication.SamplesDir;
testFile = System.String.Concat("C:\test\ZPO\Diode sample.ZMX");
NSCE = TheSystem.NCE;
Obj1 = NSCE.GetObjectAt(1);
Source_Color=Obj1.SourcesData.SourceColor;
Source_Color=ZOSAPI.Editors.NCE.SourceColorMode.SpectrumFile;
filesAvailable = Obj1.SourcesData.SourceColorSettings.GetAvailableSpectrumFiles();
FileToSelect=filesAvailable(6);
Obj1.SourcesData.SourceColorSettings.SpectrumFile=FileToSelect;
Python Code:
testFile = r"C:\test\ZPO\Diode sample.ZMX"
TheSystem.LoadFile(testFile, False)
print(TheSystem.SystemFile)
NSCE = TheSystem.NCE
Obj1 = NSCE.GetObjectAt(1)
Source_Color=Obj1.SourcesData.SourceColor
Source_Color=ZOSAPI.Editors.NCE.SourceColorMode.SpectrumFile
filesAvailable = Obj1.SourcesData.SourceColorSettings.GetAvailableSpectrumFiles()
Obj1.SourcesData.SourceColorSettings.SpectrumFile=filesAvailablel1]
print(Obj1.SourcesData.SourceColorSettings.SpectrumFile)