Performing an Expert Check Using the KWE Advanced Language

This task explains how to create a check using the KWE Advanced Language. In this scenario, you are going to create a check that looks for the tapered holes into which you will not be able to insert a screw.
  1. Click the Expert Check icon (kwxWKChecks.gif (1236 bytes)).

  2. In the Check Editor scrolling list, select KWE Advanced Language and click OK.

You can now create a check using the KWE Advanced language.

Note that:

ascenari.gif (1364 bytes)
  1. Open the KwxAdvancedCheck.CATPart file. The following document is displayed:

  2. From the Start > Knowledgeware menu, access the Knowledge Expert workbench.

  3. Click the Expert Check icon (kwxWKChecks.gif (1236 bytes)). The Check Editor dialog box is displayed.

  4. In the Language scrolling list, select the KWE Advanced Language (see picture opposite). Click OK.

     
  5. In the For All field (KweExpertQS.gif (1253 bytes)), enter the feature type that you want to apply to the expert rule. The following syntax must be applied: Pad1:Pad

  1. Copy/Paste the code below into the edition box and click OK when done:

    /* Set the local variables */
    let MyListOfHole(list)
    let MyListOfPad(list)
    let MyTupleFailed (list)
    let MyTupleSucceeded (list)
    let MyHole(Hole)
    let MyPad(Pad)
    let MyHoleBody(Body)
    let MyPadBody(Body)
    let MyOwner (BodyFeature)
    let i = 1

    /*Go to the root and look for all the Pads */
    set MyOwner = Pad1.Owner
    MyListOfPad = MyOwner.Owner > Query("Pad","")

    /* Go to the PartBody and look for the Holes */
    MyListOfHole = Pad1.Owner > Query("Hole","")

    /* Filter the threaded holes */
    MyListOfHole > Filter("Hole","X.Threaded == true")

    for i while i<=MyListOfHole > Size()
    {
    MyHole = MyListOfHole > GetItem(i)

    for MyPad inside MyListOfPad
    {
    /* Filter the Pad Pad Pad1 */
    if (Pad1.Name <> MyPad.Name)
    {
    /* Check that the direction of MyHole is identical to the direction of the Pad plane */
    if (MyHole.GetAttributeString("Direction") == MyPad > GetAttributeString("Plane") )
    {
    /* Cast Hole and Pad in the type Body (distance has "Body" type argument) */
    set MyHoleBody = MyHole
    set MyPadBody = MyPad

    /* Distance between this Hole and this Pad is lower than 35 mm */
    if (distance(MyHoleBody,MyPadBody) < 35 mm)
    /* for the report */
    ThisCheck.AddTupleFailed(MyHoleBody,MyPadBody)
    else
    ThisCheck.AddTupleSucceeded(MyTupleSucceeded)
    }
    else
    ThisCheck.AddTupleSucceeded(MyHoleBody,MyPadBody)
    }
    }
    i = i+1
    }
  2. Right-click the rule base in the specification tree, and select RuleBase object > Manual Complete Solve, or click the Solve icon (). The check icon turns to red indicating that the check failed.

  3. Right-click the rule base in the specification tree, and select RuleBase object > Report..., or click the Report icon (). The check icon turns to red indicating that the check failed. Select the directory and click OK. The report is displayed.

aendtask.gif (1477 bytes)