## Using an Alignment Inside Loops

PC-DMIS 3.6 and higher facilitates changing alignments inside a part program that uses looping or conditional branching by using the USE_ACTIVE_ALIGNMENT keyword.

If you look at the ALIGNMENT/START command line in Command mode, you'll see that the field immediately following the RECALL: text tells the program to use a stored starting alignment first. In the following example, alignment D_1 starts with the alignment from D_0 and then executes a 45 degree rotation about ZPLUS:

D_1 =ALIGNMENT/START,RECALL:D_0, LIST= YES
ALIGNMENT/ROTATE_OFFSET,45.0,ABOUT,ZPLUS
ALIGNMENT/END

However, if you use the USE_ACTIVE_ALIGNMENT keyword instead, you can cause PC-DMIS to rotate 45 degrees from the active alignment:

D_1 =ALIGNMENT/START,RECALL:USE_ACTIVE_ALIGNMENT, LIST= YES
ALIGNMENT/ROTATE_OFFSET,45.0,ABOUT,ZPLUS
ALIGNMENT/END

When you use this keyword for an alignment inside a loop:

- The first time through the loop the active alignment will be the last executed alignment preceding the loop.

- Additional times through the loop the active alignment will be itself and will rotate a further 45 degrees from the previous time through the loop.

When you use the USE_ACTIVE_ALIGNMENT keyword you should generally deselect the Reset global settings when branching check box and select the Treat theo values as if stored in part coordinates check box from the SetUp Options dialog box, General tab.
See the "Setting Your Preferences" section for information on specifying setup preferences.

For information on looping, see the "Creating Generic Loops" topic in the "Branching by Using Flow Control" section.