This code uses the numeric values for Dtypes. It loops through each axis of this dimension and looks at the out-of-tolerance value. The return value is initialized to 1 (True). If a non-zero out-of-tolerance value is found, it sets the return value to 0 (False).

This code is identical to the previous code except that the return values are reversed. The return value is initialized to 0 (False). If a non-zero out-of-tolerance value is found, it sets the return value to 1 (True).

#### Step 5: Add VB Script Code to CADONLYREF_ID.RTP

In this step, using the Report Template Editor, you will add script code to CADONLYREF_ID.RTP at each place in the rule tree that references REFERENCE_ID.LBL to check to see if the dimension is in tolerance. If it is in tolerance, the code will cause it to use REFERENCE_ID_COLOR.LBL. If it is not, the code will cause it to use LEGACY_DIMENSION_CAD.LBL.

1. While still In the Edit Rule dialog box, click Use Additional Expression or Script, select the Script option, and then click the Edit button. The VBS Mini-Editor appears.

2. Insert the following code into the VBS Mini-Editor:

Dim Count As Integer Dim CurrentOutTol As Variant Dim I As Integer ' iRetVal = 1 if In-Tolerance; iRetVal = 0 if Out-of-Tolerance iRetVal = 1

' 132 = Dtype AXIS

Count = ReportData.GetCount(132)

' Loop through each axis to see if OutTol is non-zero

For I = 1 to Count

' 344 = Dtype DIM_OUTTOL

CurrentOutTol = ReportData.GetValue(344, I)

If CurrentOutTol > 0 Then

iRetVal = 0

Exit For

End If

Next I

Explanation of Code:

3. Once you have added the code, click OK. The Mini-Editor will check for any syntax errors. If you have an error in your code, a message is displayed at this time. If there aren't any errors, the VBS Mini-Editor closes.

4. Click the Add button to define a new rule. The Edit Rule dialog box appears.

5. In the Label Name box, select or type LEGACY_DIMENSION_CAD.LBL.

6. Again, click Use Additional Expression or Script, select the Script option, and then click the Edit button. The VBS Mini-Editor appears.

7. In the VBS Mini-Editor, insert the following code:

Dim Count As Integer Dim CurrentOutTol As Variant Dim I As Integer ' iRetVal = 1 if In-Tolerance; iRetVal = 0 if Out-of-Tolerance iRetVal = 0

' 132 = Dtype AXIS

Count = ReportData.GetCount(132)

' Loop through each axis to see if OutTol is non-zero

For I = 1 to Count

' 344 = Dtype DIM_OUTTOL

CurrentOutTol = ReportData.GetValue(344, I)

If CurrentOutTol > 0 Then

iRetVal = 1

Exit For

End If

Next I

Explanation of Code:

8. Once you have added the code, click OK. The VBS Mini-Editor will check for any syntax errors. If you have an error in your code, a message is displayed at this time. If there aren't any errors, the VBS Mini-Editor closes.

9. Click OK to close the Edit Rule dialog box.