I am unable to set the source sampling in NSC; here is my code:
led_source = TheNCE.GetObjectAt(1)
led_source_type = led_source.GetObjectTypeSettings(ZOSAPI.Editors.NCE.ObjectType.SourceRadial)
led_source.ChangeType(led_source_type)
led_source.SourcesData.PrePropagation = -1
print("Preprop: ", led_source.SourcesData.PrePropagation)
print("Sampling: ", led_source.SourcesData.SamplingMethod)
led_source.SourcesData.SamplingMethod = "Sobol"
print("Sampling: ", led_source.SourcesData.SamplingMethod)
Note Pre-propagation can be [set, get] through SourceData, whereas SamplingMethod can only be [get]. When I execute this code I get the following:
Preprop: -1.0
Sampling: Sobol
Traceback (most recent call last):
File "C:\Users\matthew.haines\Documents\Zemax\ZOS-API Projects\PythonStandaloneApplication4\PythonStandaloneApplication4\PythonStandaloneApplication4.py", line 226, in <module>
led_source.SourcesData.SamplingMethod = "Sobol"
TypeError: since Python.NET 3.0 int can not be converted to Enum implicitly. Use Enum(int_value)
Exception ignored in: <function PythonStandaloneApplication4.__del__ at 0x00000283CB6D1820>
Traceback (most recent call last):
File "C:\Users\matthew.haines\Documents\Zemax\ZOS-API Projects\PythonStandaloneApplication4\PythonStandaloneApplication4\PythonStandaloneApplication4.py", line 75, in __del__
TypeError: 'MethodObject' object is not callable