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.
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.
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
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.
Click the Add button to define a new rule. The Edit Rule dialog box appears.
In the Label Name box, select or type LEGACY_DIMENSION_CAD.LBL.
Again, click Use Additional Expression or Script, select the Script option, and then click the Edit button. The VBS Mini-Editor appears.
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
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.
Click OK to close the Edit Rule dialog box.