Skip to main content

I have set the ‘Scatter To Method’with the commond ‘...ScatterToData.ScatterToMethod = 1’, then I wanna set the Ray data as shown in Fig. 1, but I failed to call the function ‘SetRayData’.

According to the Ansys Developer Guideline as shown in Fig. 2/3, it doesnt give more details, I have tried to infer corresponding code but cant work.

Fig. 1

Fig. 2

Fig. 3

@Borui 

 

As you can see, SetRayData takes a IImportanceSamplingSettings as input parameter. To create such an object, you can leverage GetRayData, which returns exactly such an object. It doesn’t matter which one you get, since you’ll be overwritting it anyway.

Here is a Python example:

object_1 = TheSystem.NCE.GetObjectAt(1)
scatterto_data = object_1.ScatterToData

scatterto_data.ScatterToMethod = ZOSAPI.Editors.NCE.ScatterToType.ImportanceSampling

ray_data = scatterto_data.GetRayData(1)
ray_data.Towards = 3
ray_data.Size = 1.23
ray_data.Limit = 4.56

scatterto_data.SetRayData(1, ray_data)

I hope this helps and take care,


David


@Borui

 

As you can see, SetRayData takes a IImportanceSamplingSettings as input parameter. To create such an object, you can leverage GetRayData, which returns exactly such an object. It doesn’t matter which one you get, since you’ll be overwritting it anyway.

Here is a Python example:

object_1 = TheSystem.NCE.GetObjectAt(1)
scatterto_data = object_1.ScatterToData

scatterto_data.ScatterToMethod = ZOSAPI.Editors.NCE.ScatterToType.ImportanceSampling

ray_data = scatterto_data.GetRayData(1)
ray_data.Towards = 3
ray_data.Size = 1.23
ray_data.Limit = 4.56

scatterto_data.SetRayData(1, ray_data)

I hope this helps and take care,


David

perfect solution to my confusion, thanks!


Reply