Instantiating a User Feature Using the Knowledge Pattern  

The task below shows how to instantiate a User Feature using the Knowledge Pattern. This scenario is based on ARM and on the new Knowledge directories structure. For more information, see CATIA Infrastructure User's Guide: Advanced Tasks: Using Knowledgeware Capabilities: Managing Knowledge Applications Resources.
To perform this scenario, you will need the following files:
This document contains a User Feature that will be instantiated from the Knowledge Pattern. The inputs of this User Feature are 2 planes.
This file contains the information concerning the typed User Feature.
This document will contain the Knowledge Pattern and the instantiated User Features.
This document is the ARM catalog referencing the physical resources used in this scenario.
Before performing this scenario, make sure that you have:
  • Selected the directory that contains the PktBox.CATGScript in the Reference Directory For Types field in the Tools>Options>General>Parameters and Measures>Knowledge Environment tab.
  • Selected the Architect Resources Creation Path in the Tools>Options>General>Parameter and Measures>Knowledge Environment tab. Remember that the directory selected here can only be the knowledge directory of the Knowledge directories structure. For more information about this structure, see CATIA Infrastructure User's Guide: Advanced Tasks: Using Knowledgeware Capabilities: Managing Knowledge Applications Resources in the .

Save the Required Data into the New Directories Structure

  1. Save the provided data in the appropriate directories:

    • Save PktBoxUDF.CATPart in the CATKnowledgePath\knowledge\knowledgeResources directory.
    • Save PktARMcatalog2.catalog in the CATKnowledgePath\knowledge\knowledgeResourcesCatalogs directory.
    • Save PktBox.CATGScript in the knowledgeTypesCustom directory referenced in the Reference Directory For Types.
  2. Open the PktQuantifierUDF.CATPart file.

Create the NbInstances Parameter

This parameter will enable you to determine the number of User Features you want to instantiate

  1. Click the Formula icon (). The Formula editor opens.

  2. In the New parameter of type combo box, select Integer and click New parameter of type.

  3. In the Edit name or value of the current parameter field, double-click Integer.1 and enter NbInstances. Click OK. The NbInstances parameter is created.

Create the Knowledge Pattern

This feature will enable you to instantiate the User Features

  1. From the Start>Knowledgeware menu, select the Product Knowledge Template workbench.

  2. Click the Create a Knowledge Pattern icon (). The Knowledge Pattern Editor opens.

  3. Enter the following code in the editor or copy/paste the code contained in this file:

    let udf (PktBox) 1
    let prev (PktBox)
    1
    let p (Plane)
    1

    let i (Integer)
    1

    i = 1

    For i while i <= NbInstances
    2
                  {
                 
     udf = CreateOrModifyTemplate("PktARMcatalog2|BoxUDF", PartBody, Boxes, i)
                  if i == 1
                            udf.BoxInputPlane = FirstBoxPlane
    3
                  else
                  {
                            prev = Boxes.GetItem(i - 1)
                            udf.BoxInputPlane = prev.NextBoxInputPlane

                            udf.PreviousBoxLength = prev.L
                   }
                   udf.SketchPlane = SketchPlane

                   EndModifyTemplate(udf)

                   udf.Name = "Box" + ToString(i)
    4

                   i = i +1
    }
    In the script above, you first declare the local variables (1), 2 corresponding to the type associated to the User Feature (in the .CATGScript file), then a plane and an integer. Then you perform a loop based on the number of instances set by the NbInstances parameter (2). The loop instantiates the User Features contained in the PktARMcatalog2 catalog via the CreateOrModifyTemplate function into the PartBody.
    When instantiating the first User Feature, i=1, the input of the User Feature is FirstBoxPlane (3). For the other instantiations, the input of the User Feature is the plane of the last instantiated User Feature. The length of the instantiated User Feature corresponds to the exposed parameter (L) of the last User Feature instantiated. At the end of the instantiation process, a name is assigned to the instantiated User Feature. This name is based on the concatenation of "Box" and the number associated to the User Feature. (4).
  4. Click Add. List.1 = 0 elements is displayed in the Knowledge Pattern Lists field. This list will list the number of instantiated User Features.

  5. Click it and replace it with Boxes in the Name field.

  6. In the Mode combo box, select Automatic execution (before root update). This way, when you change the number of desired instantiated User Features, the script will be launched automatically.

  7. In the specification tree, click the NbInstances parameter. Use the spin box to indicate the number of instances you want to instantiate (5 in this scenario.)

  8. Click Execute now. The 5 boxes are instantiated. Click OK to close the Knowledge Pattern window.

  9. Double-click twice the parameter in the specification tree. The Edit parameter dialog box displays.

  10. Use the spin box to set the number of instances to 3 and click OK. 2 instances are removed. Click here to open the Part containing the Knowledge Pattern.