## Using an Alignment Inside Loops or Branches

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 following the RECALL: text within your ALIGNMENT/START command. This keyword lets you recall the active alignment.

The USE_ACTIVE_ALIGNMENT keyword will also display the name of the active alignment within parentheses. So, if the active alignment was A3 during the last execution, the keyword would show the following after execution:

USE_ACTIVE_ALIGNMENT(A3)

PC-DMIS uses the active alignment name for different purposes depending on whether PC-DMIS is in learn or in execute mode.

- In learn mode, changing the alignment name in parentheses does not have any bearing on the actual active alignment used or displayed during execution. In learn mode this name is merely used as a tool for you to visualize different scenarios that may occur during execution. You can visualize what may occur by changing the active alignment in parentheses and watching the trihedron move to that alignment's coordinate system in the Graphics Display window.

- In execute mode, PC-DMIS will decide which alignment is active based on the last executed alignment. This will be dependent on any branching and looping that occurred during execution. After execution, the actual alignment which was active during the last execution will be displayed in parentheses.

Also, the alignment name in parentheses is now saved with the part program. When opening a part program created prior to PC-DMIS 2010 MR2, the information that appears in parentheses is dynamically populated by PC-DMIS as it searched for alignments above the alignment with the USE_ACTIVE_ALIGNMENT setting. This happens regardless of commands that may affect program flow during execution, such as looping or branching commands.

Note: Part programs that have been imported from a DMIS file into PC-DMIS do not support the functionality of showing the alignment name in parentheses, even if you save the file as a new part program.

USE_ACTIVE_ALIGNMENT Example

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(D_0), 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.

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

Preferences that Affect USE_ACTIVE_ALIGNMENT

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.