PCB Matrix Format
by Numerical Innovations, Inc. (www.numericalinnovations.com)
FOREACH

MATRIX Array Level: 1

The <FOREACH> element allows you to do looping (on a section of matrix code).

SELECT in FOREACH
Description
Default Loops thru all visible objects.

<foreach select="default" >
<foreach select="" >
SelectionSet Assign the name of a Selection set
Loops thru all objects in the Selection set

<foreach select="Set1" >
Layers Loops through Layers.
<foreach select="Layers" >

Apertures Loops through Apertures.
<foreach select="Apertures" >

Tools Loops through availalbe NC Tools.
<foreach select="Apertures" >

Centroids Loops through Centroids.
<foreach select="Centroids" >

Nets Loops through Nets.
<foreach select="Nets" >

ExternalNets Loops through External Nets.
<foreach select="ExternalNets" >

BOM Loops through Bom List.
<foreach select="BOM" >

Packages Loops through Component Packages.
<foreach select="Packages" >

Jobs Loops through Jobs.
<foreach select="Jobs" >


Note
ForEach includes several Intrinsic variables: __index , __total
FOREACH Intrinsic variables
Description
__index Current array iterator value starting at 0
__total Total size of the array.


XML example:

<foreach select="Set1">
<get object="attribute" name=".comp_height" result="@height" />
<MESSAGE>Component Height: @height</MESSAGE>
<set object="attribute" name=".comp_height" value="0.1" />
<get object="attribute" name=".comp_height" result="@height" />
<MESSAGE>New Component Height: @height</MESSAGE>
</foreach>
<!-- Output layers to command console -->
<MESSAGE> </MESSAGE>
<MESSAGE>Layers:</MESSAGE>
<MESSAGE>---------------------------------</MESSAGE>
<foreach select="layers">
<get layer="all" />
<MESSAGE>#__layer_number: __layer_name (__layer_type)</MESSAGE>
</foreach>