Solved

Getting Y-half width in macro code

  • 9 August 2022
  • 2 replies
  • 149 views

Hello everyone,

 

In Macro code script I need to get Y half width. Which function you suggest?

Thanks fir your help in advance?

Regards,

Behzad

icon

Best answer by David.Nguyen 9 August 2022, 15:51

View original

2 replies

Userlevel 7
Badge +2

Hi Behzad,

 

Can you tell us what object/surface are you trying to get the Y Half Width from?

In my modest experience, Y Half Width is usually a parameter of an object, meaning you are probably using the Non-Sequential mode, but correct me if I’m wrong. Since you are looking for a function that retrieves a number (the Y Half Widht), it has to be a Numeric Function. In the Help File (F1), you can actually search for “Numeric Functions” and the first result should be the complete list of numeric functions available for your macros. From this list, you can find the function NPAR(surf, object, param), which returns a parameter of a non-sequential object.

Let me give you an example. In the case of a Detector Rectangle, the Y Half Width parameter is parameter number 2. If you are not sure what parameter number is a particular parameter, here is a trick for you:

  1. Insert a Null Object in your Non-Sequential Component Editor
  2. Click on the cell from the Null Object that is right above/below the Y Half Width
  3. The column of this cell will change its name to Par X, where X is the parameter number

In a Detector Rectangle, the Y Half Width is Parameter 2. If you are in pure Non-Sequential Mode, the surf argument of NPAR should be 1, the objct argument is the object number where you have your Y Half Width, and the param argument is the parameter number. In my example, you need to write the following line of code in your macro:

Y_Half_Width = NPAR(1, 2, 2)

Let me know if this makes sense.

Take care,

 

David

Thank you so much David.

you solved my problem.

Have a wonderful day

Regards,

Behzad

Reply