Feature Arrays

When a feature is measured more than once during routine execution because of some kind of loop, the software creates a feature array automatically. The number of elements in the feature array is equal to the number of times that the feature has been executed.

If a measured circle feature is inside a while loop that executes five times, then an array of five measured circles exists. If the id of the measured circle is CIR1, then you can use an array expression to access individual instances of the measured circle object. You use square brackets to indicate the instance you want, like this:

ASSIGN/V1=CIR1[3].X

V1 is assigned the measured X value of the third instance of the CIR1 circle.

When a feature array exists for a given feature, but array notation is not used in a reference to that feature, the most recent instance is used. From the above example, the reference CIR1.X would be the same as CIR1[5].X, since the fifth instance would be the most recent instance of the object.

You can use expressions within the square brackets of an array expression:

CIR1[3].X and CIR1[2+1].X would therefore be equivalent.

This next example uses two While / End While loop command blocks. The first block executes the CIR1 circle five times. The second block uses the V1 variable inside of square brackets, like this, CIR1[V1].XYZ, to send the measured centroid of each of the five executions to the Report window:

            ASSIGN/V1=1
            WHILE/V1<6
CIR1         =FEAT/CIRCLE,CARTESIAN,IN,LEAST_SQR
              THEO/<40,30,-4.824>,<0,0,1>,30
              ACTL/<40.002,29.991,-4.836>,<0,0,1>,29.982
              MEAS/CIRCLE,4,ZPLUS
                HIT/BASIC,NORMAL,<41.984,44.868,-2.885>,<-0.132272,-0.9912135,0>,<41.972,44.85,-2.891>,USE THEO=YES
                HIT/BASIC,NORMAL,<51.721,39.36,-5.094>,<-0.781412,-0.6240155,0>,<51.706,39.375,-5.107>,USE THEO=YES
                HIT/BASIC,NORMAL,<54.792,32.491,-5.44>,<-0.9861119,-0.1660821,0>,<54.775,32.474,-5.453>,USE THEO=YES
                HIT/BASIC,NORMAL,<52.526,21.748,-5.879>,<-0.8350841,0.5501223,0>,<52.537,21.764,-5.893>,USE THEO=YES
              ENDMEAS/
              ASSIGN/V1=V1+1
            END_WHILE/
            ASSIGN/V1=1
            WHILE/V1<6
              COMMENT/REPT,
              "Centroid of CIR1, instance #" + V1
              CIR1[V1].XYZ
              COMMENT/REPT,
              --------------------
              ASSIGN/V1=V1+1
            END_WHILE/

Here is the generated output to the Report window:

Generated Output of Looped Execution

Arrays also exist on dimensions and alignments that have been executed multiple times in a given execution run. Thus, Dim1[2].Nom and Align1[4].Origin would be available given that the Dimension "Dim1" has executed at least twice and the alignment "Align1" has executed at least four times.

If a feature array reference is out of bounds (for example, the user asks for CIR1[2.5] or CIR1["Hello, World"]) the upper or lower bound item is returned. If Circle1 had 3 instances then CIR1[4] and above would return the value for CIR1[3], and CIR1[0] and below would return the value for CIR1[1]. All expressions between square brackets are coerced to integer, thus 2.5 would become 2 and "Hello World" would become 0.