About Rule Firing

Configuration 4
 of KwrProfilesDesignTable.xls
applied to KwrBottleProfiles.CATPart

This scenario explains how to write rules and gives some tips about the process which is behind the rule firing. Two rules are created. One launches a macro which updates and saves the document whenever the design table configuration results in a valid check. The other starts a macro which generates an assembly with constraints.

Writing the Rules

  1. Open the KwrBottleProfiles.CATPart document.

  2. Click the Design Table icon (). In the dialog box which is displayed, check the Create a design table from a pre-existing file box. Click OK. In the file selection dialog box, select the KwrProfilesDesignTable.xls sample. Click OK in the box which asks you whether you want to associate automatically columns with parameters.  Select Configuration 2 as the active configuration. Save the document under the KwrTipCreateAssembly.CATPart name.

  3. Check that the KwrTipSave.CATScript and KwrTipCreateAssembly.CATScript macros are downloaded in your environment as well as the KwrCap1.CATPart document. In the KwrTipCreateAssembly.CATScript  macro, replace the path defining the assembly components in the var1(0) and var2(0) definitions.

  4. Deactivate the design table from the contextual menu.

  5. Access the Knowledge Advisor workbench to create the UpdateAndSaveRule rule. To do this:

    1. Click the Rule icon (). 

    2. In the first dialog box which is displayed, enter the UpdateAndSaveRule name. Click OK to display the main rule editor.

    3. In the rule editor, enter the rule below:

      if Relations\DesignTable.1\Configuration < 7 
         Message("Document update and save")
       else Message("Configuration # is invalid",

      Prior to clicking OK, replace the path specified in the LaunchMacroFromFile function with the path where you have downloaded the KwrTipSave.CATScript macro. 

    4. Click OK to add the rule to the document. A message box is displayed (Document update and save). This message box is generated by the Message function in the rule. Two Visual Basic boxes are also displayed. They are generated by the KwrTipSave.CATScript macro.

    5. Deactivate the rule.

  6. Use the same procedure to create the AssemblyRule rule below:

    if Relations\UpdateAndSaveRule\Activity == true

    Prior to clicking OK, replace the path specified in the LaunchMacroFromFile function with the path where you have downloaded the KwrTipCreateAssembly.CATScript macro. 

  7. Deactivate all the features located below the Relations node of the specification tree then save your document.

Firing the Rules

  1. Reactivate UpdateAndSaveRule. The message boxes warning about the update and save operations are displayed.

  2. Reactivate DesignTable.1 and modify the design table configuration.  To do this, double-click the design table icon in the specification tree then select a new row among the displayed configurations (from 1 to 6).

  3. Reactivate AssemblyRule. The macro which creates the assembly is launched. You get on screen a message warning you that an assembly is going to be created. Click OK in the Visual Basic message box.  The assembly is generated. You can see the different steps on screen.

    Once the macro has finished running, close the product which has been generated, then deactivate AssemblyRule.

  4. Go back to the initial document. Modify again the design table configuration. The UpdateAndSave macro is launched but not the AssemblyRule macro which is deactivated. To create the assembly corresponding to the new configuration, reactivate AssemblyRule.