Skip to main content
Solved

How to use 'SetRayData' in ImportanceSampling Interface?


Borui

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

Best answer by David.Nguyen

@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

View original
Did this topic help you find an answer to your question?

2 replies

David.Nguyen
Luminary
Forum|alt.badge.img+2
  • Luminary
  • 1072 replies
  • Answer
  • July 18, 2024

@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
  • Author
  • Monochrome
  • 3 replies
  • July 19, 2024
David.Nguyen wrote:

@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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings