Checking with Knowledge Advanced Language and Correcting Function with VB Script

This task explains how to create a check and use a VB correction method to make the invalid features fulfill the check.
  1. Open the KwxUseCase1.CATPart document. 
    This document is a draft built from a rectangular pad. Three holes are evenly distributed along the draft length.

  2. Right-click Hole.1 and select Properties. In the Update Status frame, check the Deactivated check box. Click OK to close the window.

  3. Access the Knowledge Expert workbench, then click the icon. In the dialog box which is displayed, select KWE Advanced Language, enter a check name and a comment, then click OK. The check editor is displayed.

  4. Select the Condition tab and enter the check below:

    (for all) H:Hole
    if H.Activity == FALSE
           ThisCheck.AddTupleFailed(H)
    else
           ThisCheck.AddTupleSucceeded(H)
  5. In the Correction tab, select VB Script as correction method and enter the script below into the edition box:

    H.Activity = TRUE
  6. Click OK to add the check to the rule base, then click the icon to solve the rule base. In the specification tree, the check icon is red indicating that not all the part holes are activated.

  7. Right-click Hole.1 and select Correct Function. The Correct Function is executed and the hole's activity is changed. Then click the icon to solve the rule base. The check icon is now green.

 In the example H, if you use AddTupleFailed method and not the variable define into the part, you must use the correction tab specific instructions to apply the correction to the right variable.
For Example,
(for all) H:Hole
if H.Owner.Name == "PartBody2"
       ThisCheck.AddTupleSucceeded(H.Owner)
else
       ThisCheck.AddTupleFailed(H.Owner)

This check verifies if the owner of the name of each hole is PartBody2.

Correct function,
Dim listTupleFailed() as Object
ElementSize = ThisCorrectFunction.GetNumberOfListFailedElements
ReDim listTupleFailed (ElementSize - 1)
ThisCorrectFunction.ListFailedElements (listTupleFailed)
For compt = LBound(listTupleFailed) to UBound(listTupleFailed)
  listTupleFailed(compt).Name =
"PartBody2"
Next