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:

  1. Once you have added the code, click OK. The Mini-Editor checks for any syntax errors. If you have an error in your code, PC-DMIS displays a message at this time. If there aren't any errors, the VBS Mini-Editor closes.

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

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

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

  5. 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:

  1. Once you have added the code, click OK. The VBS Mini-Editor checks for any syntax errors. If you have an error in your code, PC-DMIS displays a message at this time. If there aren't any errors, the VBS Mini-Editor closes.

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

Goto Previous Tutorial StepGoto Next Tutorial Step