Languages in Quality Rules Reuse and Quality Rules Capture

This section provides you with information about the languages you can select in Quality Rules Reuse and Quality Rules Capture It also shows you how to create checks and rules. To know more about the Enterprise Knowledge Language, see the Enterprise Knowledge Language Reference Guide.

This page discusses:

Select a Language

  • When defining rules in Quality Rules Reuse, you can use the Knowledge Language or Visual Basic.
  • When defining checks in Quality Rules Reuse, you can use three languages:

  • Enterprise Knowledge Language enables you to use local variables and control structures (if then else, for, while). You can also fill in a list of succeeded and failed objects used when generating the report (only when creating checks). This topic introduces the use of this language in the checks.
  • Knowledge Language is more limited than the EKL but more optimized when using attributes only.
  • Visual Basic Language is not introduced totally in this guide as it follows its own syntax rules. The use of this language in checks is described.

Create a Check Using Enterprise Knowledge Language

If you want to indicate that a check is valid (or not), use the AddNewTuple method.

  1. Enter the statement in the Name area to specify that the check is to be applied to all dimensions. To do so:
    1. Double-click Add new argument and enter the argument name.
    2. Select the type in the Type list.
  2. Copy and paste the following script to the editor and click Apply to test the syntax.

    In the following example, dim is the argument name and TPSDimensionAnnot is the type:

    let dimMax (Length)
    dimMax = 15mm
    if(dimDimensionType == DrwDimDistance
    {
          if(dim.DimensionValue >= dimMax)
                 ThisCheck.AddNewTuple(True, dim)
          else
                 ThisCheck.AddNewTuple(False, dim)
    }

  3. Click OK. A check is added to the rule base in the tree.

Create a Check Using Knowledge Language

Use only the if statement. Note that if constructs cannot be nested.

  1. Enter the statement in the Name area to specify that the check is to be applied to all dimensions. To do so:
    1. Double-click Add new argument and enter the argument name.
    2. Select the type in the Type list.
  2. Copy and paste the following script to the editor and click Apply to test the syntax.

    In the following example, dim is the argument name and TPSDimensionAnnot is the type: dim.DimensionType == "DrwDimDistance" AND dim.DimensionValue > 10mm.

    Note: You can also use the OR keyword.
  3. Click OK. A check is added to the rule base in the tree.

The filter operator (=>) can be used only in checks written in Knowledge Language. In this case, the previous script can be replaced with the following one: dim.DimensionType == "DrwDimDistance" => dim.DimensionValue > 10mm. All TPSDimensionAnnot objects that do not comply with dim.DimensionType == "DrwDimDistance" are excluded from the results.

Create a Check in Visual Basic

If you want to indicate that a check is valid (or not), set the Value attribute of the return Value object to 1 if the check is valid, or to 2 if the check is invalid.

  1. Enter the statement in the Name area to specify that the check is to be applied to all dimensions. To do so:
    1. Double-click Add new argument and enter the argument name.
    2. Select the type in the Type list.
  2. Copy and paste the following script to the editor and click Apply to test the syntax.

    In the following example, dim is the argument name and TPSDimensionAnnot is the type:

    Dim dbottom As double
    Dim dup As double
    If DimAnnot.HasDimensionLimit Then
          DimAnnot.DimensionLimit.Limits dbottom, dup
          if dbottom < -0.01 Then
                     returnValue.Value = 0
          else
                     returnValue.Value = 1
          end if
    else
          returnValue.Value = 0
    end if

    Note: If not unit is indicated in the VB script, the default unit is mm.

Create a Rule Using the Knowledge Language

Use only the if statement. Note that if constructs cannot be nested.

  1. Enter the statement in the Name area to specify that the check is to be applied to all dimensions. To do so:
    1. Double-click Add new argument and enter the argument name.
    2. Select the type in the Type list.
  2. Copy and paste the following script to the editor and click Apply to test the syntax.

    In the following example, dim is the argument name and TPSDimensionAnnot is the type:

    if (dim.DimensionType == "DrwDimeditionDistance" AND DimensionValue > 10mm
    {
            dim.DimensionValue = 10mm
    }

  3. Click OK. A rule is added to the rule base in the tree.