Creating Rules and Checks in VB Script

atarget.gif (1372 bytes)

The scenario below illustrates how to use a variable and specify a return value. 

Instead of writing the body of expert rules and checks in the Knowledge Expert language, you can write it in VB script. There are some adjustments to be done:

  • The variable declared in the (for all) field can be used as an object.
  • The indicated type name in Knowledge Expert Language may change in VB script.
  • To specify that a check is valid or not, set the Value attribute of the returnValue object ( 1 if the check is valid, 0 if the check is invalid).
ascenari.gif (1364 bytes)
  1. Open the KwxUseCase1.CATPart document.

  2. Access the Knowledge Expert workbench, then click the kwxWKChecks.gif (1236 bytes)  icon. In the dialog box which is displayed, enter a check name and a comment. Select the Visual Basic language (KWE language is the default language), then click OK. The three tab editor is displayed.

  3. Select the Condition tab and enter the check below (Do not use comments starting with /* and ending with  */. Remove these comments).

    (for all) H:Hole

    Dim diam As Length
    Set diam = H.Diameter

    if (diam.Value >= 10.0 ) then
    returnValue.Value = 1
    else
    returnValue.Value = 0
    end if
  • If no unit is indicated in VB script, the default unit will be mm; and m in Knowledge Expert Language. 

  • It is highly recommended not to add any comments (between '..') in VB script or a syntax error will be returned.

  1. 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 green. This indicates that all the part holes have a diameter greater than or equal to 10mm.

awarning.gif (1007 bytes)