Solved

NSC Ray trace of chosen source

  • 21 November 2022
  • 4 replies
  • 149 views

Userlevel 2

Hello,

Is there a way to choose which source I want to raytrace in ZOS-API?

In ZPL I’m familiar with the NSTR property but didn’t see similar property in the INSCRayTrace Tool.

 

Thanks,

Oran

icon

Best answer by David.Nguyen 21 November 2022, 16:07

View original

4 replies

Userlevel 7
Badge +2

Hi Oran,

 

The INSCRayTrace Tool is the equivalent of pressing Analyze..Ray Trace in the user interface, which prompt you with the following window:

And if you look into the Help File for this tool (using the blue question mark icon), you’ll read that:

OpticStudio will trace exactly the number of specified analysis rays for each source listed in the NSC Editor

 

So, if you want to use that tool, you could disable a Source by setting its # Analysis Rays cell to zero. Since this is Parameter 2 of a source, this is the line of code you’ll need (Python in this example):

# Get your Source Object
My_Source_1 = TheSystem.NCE.GetObjectAt(1)

# Set its # Analysis Rays to zero
My_Source_1.GetObjectCell(12).IntegerValue = 0

Alternatively, if you want to enable a Source, just set its # Analysis Rays to any non-zero positive integer.

 

NSTR in ZPL works more like the NSTR Merit Function operand and you could use the Merit Function to perform the ray tracing and retrive the value of some other operands (but it wouldn’t work for an analysis). I hope this makes sense.

 

Lastly, you could also use the IBatchRayTrace tool, and in this case, instead of defining a source, you would define the rays you want to be traced individually.

 

I hope this helps and take care,

 


David

Userlevel 2

 

NSTR in ZPL works more like the NSTR Merit Function operand and you could use the Merit Function to perform the ray tracing and retrive the value of some other operands (but it wouldn’t work for an analysis). I hope this makes sense.

 

Can you please explain what did you mean buy saying it wouldn’t work for an analysis?

I figured I would use NSTR through the MFE but I want to understand the implications.

 

Thanks,

Oran

Userlevel 7
Badge +2

Hi Oran,

 

Let’s imagine you are using the Analyze..Ray Database Viewer in the user interface. This analysis requires a ray database in the form of a *.ZRD file. Using the NSTR Merit-Function operand will not generate such a file by default (but the ZPL keyword could). In the ZOS-API you would have to add a NSRD operand before to specify the ray database file name, and then, you could run this analysis with the file that has been generated with the Merit Function. For other analyses you might run into similar issues. I shouldn’t have said that it wouldn’t work, instead what I mean is that it might be more tricky than simply having a NSTR operand in the Merit Function.

I hope that makes sense.

Take care,


David

Hi Oran,

 

The INSCRayTrace Tool is the equivalent of pressing Analyze..Ray Trace in the user interface, which prompt you with the following window:

And if you look into the Help File for this tool (using the blue question mark icon), you’ll read that:

OpticStudio will trace exactly the number of specified analysis rays for each source listed in the NSC Editor

 

So, if you want to use that tool, you could disable a Source by setting its # Analysis Rays cell to zero. Since this is Parameter 2 of a source, this is the line of code you’ll need (Python in this example):

# Get your Source Object
My_Source_1 = TheSystem.NCE.GetObjectAt(1)

# Set its # Analysis Rays to zero
My_Source_1.GetObjectCell(12).IntegerValue = 0

Alternatively, if you want to enable a Source, just set its # Analysis Rays to any non-zero positive integer.

 

NSTR in ZPL works more like the NSTR Merit Function operand and you could use the Merit Function to perform the ray tracing and retrive the value of some other operands (but it wouldn’t work for an analysis). I hope this makes sense.

 

Lastly, you could also use the IBatchRayTrace tool, and in this case, instead of defining a source, you would define the rays you want to be traced individually.

 

I hope this helps and take care,

 


David

Dear Dvid,

Thank you for the information! I have the following questions:

  1. Where I can find the IBatchRayTrace tool?
  2. Your code shown above is the Python API. How can I implement this in ZPL macro?
  3. If I want to weight the source diodes through ZPL macro, is is so simply that I just need to use SetNSCParameter and change parameter 3 for each source diodes? (I didn’t have a chance to verify it yet...)

Regards,

Jiang

Reply