About the Knowledge Pattern Feature

A Knowledge Pattern is a feature that enables you to instantiate templates or datums into CATPart documents in batch mode (without user interaction). It also enables you to manage the instantiated objects in an associative way. It allows to generate automatically repetitive structures as well, with differences between each instance from the structure.

Related Topics
About the Knowledge Pattern Editor
Generating Datum Objects Using the Knowledge Pattern

Creating a Knowledge Pattern Feature

You can create a Knowledge Pattern object by clicking Create Pattern a Knowledge Pattern Feature. .

The objects that are supported by this feature are the:


  • User features.
  • Datums (Points, Lines, Curves, Circles, Surfaces, Planes, Volumes).

The Knowledge Pattern feature is aggregated to the Relations node from the specification tree, into a part.

The Knowledge Pattern feature is very similar to the Action feature. Like the Action feature, it contains an expressional part that allows you to specify what actions you want to perform usually using loops and the for keyword. The main differences between both features are the following:

  1. When creating a Knowledge Pattern feature, you can create lists which are aggregated to Knowledge Pattern features. These lists contain links to the created objects, and the Knowledge Pattern feature controls the life cycle of the created objects through the content of these lists.

    Note: It can be useful to create several lists to handle different kind of objects. It provides an easy access to the results that have different semantics.

  2. You can use methods available in the dictionary to handle the instantiation and the modification of Knowledge Templates, and to create or modify datum objects.
  3. You can specify the update behavior of the Knowledge Pattern feature: Automatic update before the document root feature ( part, product, …) update, Manual update, Object update (the pattern can be updated through a reaction: In this case, make sure that you do not select the Automatic update mode).
  4. You can specify what happens if the controlled objects are pointed by other objects, when the pattern is executed another time.

Knowledge Pattern Specific Functions

You can instantiate a template by using the Knowledge Pattern feature.

The Knowledge Pattern allows to conditionally instantiate a template or another depending on some specifications (if … then instantiate A else instantiate B). The index in Knowledge Pattern lists enables you to identify the template. If a call is made to instantiate with index i in list L, the application looks for an instance in the list at this position.

  • If no instance is found, an instance is created and inserted into the list L at the position i.
  • If an instance is found, the application compares the identifier given as first argument with the one that was used for the previous instance. If this identifier is different, the system instantiates the new template and replaces the previous instance with a new one. This replace operation reroutes links from the old instance to the new one. Naming is copied from the previous instance.

The generative functions specific to Knowledge Pattern enable you to work with the Knowledge Pattern feature:

  1. CreateOrModifyTemplate: This method enables you to instantiate a user feature. You can access and modify the inputs of this user feature by using the type attributes (xxx.input name or xxx. output name) and the published name.

    - TemplateId: Either the name of the resource in the resource table or the name of the local user feature.

    - Destination: Indicates the destination object (PartBody, ...).

    - PatternList: Indicates the pattern list.

    - IndexInPatternList: Indicates the index number in the pattern list. The function usually waits for contiguous indexes from 1 to n. 0 index is accepted but has the meaning of systematically appending created object at the end of the list, so 0 index should not be used in conjunction with non null indexes.

    If an object is removed from the list before the end of the pattern, or is replaced by another one at its index, it is deleted at the end of the pattern execution.

    The syntax here has to be the following:

    udf = CreateOrModifyTemplate("BoxUDF", PartBody, Boxes, i)
    udf = CreateOrModifyTemplate("UserFeature1", `Geometrical Set.1` , Boxes, i)

  2. EndModifyTemplate: Enables you to trigger the update of the instantiated Object after modifying its inputs.

    - Feature: object returned by the CreateOrModifyTemplate function. The EndModifyTemplate function can only be used together with the CreateOrModifyTemplate and the InstantiateTemplate ones.

    The Syntax is the following: EndModifyTemplate(udf)

  3. IsPatternInstanceLocked: This method enables you to ask if an instance is locked.

    - Feature: if the answer is true, the instance is locked. If the answer is false, the instance is not locked.

  4. LockPatternInstance: This method enables you to lock the instance instantiated by the CreateOrModifyTemplate or CreateOrModifyDatum functions hence avoiding the modification of this instance. A new affectation or an attribute modification does not modify the instance.

    - patterninstance: Indicates the pattern.

    - doLock: If set to true, the instance is locked. If set to false, the instance is not locked.

  5. CreateOrModifyDatum: This method enables you to create or modify a datum.

    - datumType: Indicates the datum type (Point, Line, Curve, Circle, Surface, Plane, Volume).

    - Destination: Indicates the destination Object (PartBody, ...).

    - PatternList: Indicates the pattern list.

    - IndexInPatternList: Indicates the index number in the pattern list.

Note: You can handle attributes using the Type view (if the type was properly generated and referenced in the Knowledge Environment tab) or using the SetAttributeObject function.

Concerning Associativity and Lists

The Knowledge Pattern ensures the associativity of created objects.

This associativity is ensured with respect to:

  1. The parameters values of these objects. As an example, the templates publish parameters and a value change can impact the geometry of the instances.
  2. The number of objects to generate.
  3. The templates themselves. Depending on some expressional conditions or input changes, the templates to instantiate can change.
  4. The inputs of the expressional object defining the Knowledge pattern.
  5. The Inputs of these objects. The inputs can be geometrical inputs or parametric ones. The inputs of the expression are the objects that are not used as l-values (that are not set by an affectation operation).

To manage associativity, the Knowledge Pattern uses:

  1. The Engineering Knowledge Language (EKL) which contains loop structures and conditional expressions and that allows to instantiate and modify templates. It also allows to instantiate datums and templates and modify created instances using the Generative Knowledge functions.
  2. Lists that contain all objects and identify them in a unique way. These lists contain the Knowledge Pattern instantiated objects. They are published, enabling you to access the objects in other expressional objects. The Knowledge Pattern feature controls the life cycle of the objects grouped in these lists.

The List features is aggregated under the Knowledge Pattern feature (including the list containing locked objects).

Using the Locking Tool

This tool allows to lock generated objects.

The Knowledge Pattern feature provides you with a way to lock the generated objects so that further executions cannot modify them. There are 2 ways to lock these objects:

  • By manually adding or removing the generated object from the LockedInstances list from the pattern.
  • Use the dedicated function added to the Engineering Knowledge Language (EKL) to perform this action.

When executing the Knowledge Pattern feature, you cannot modify nor delete the locked objects even if:

  • You use the Generative Knowledge functions and if the arguments change.
  • You re-execute the pattern without calling the CreateOrModify function for this object.
  • You use affectation operators when creating datums.
  • You try to write object attributes (except if you use the SetAttribute.xxx methods).

Using the Knowledge Pattern Contextual Menu

The Knowledge Pattern contextual menu enables to access the Knowledge Pattern definition window thanks to the Definition command, to execute the Knowledge Pattern thanks to the Execute command. The Execute and upgrade command loads the Parts referenced by the Knowledge Pattern. The user feature version is checked and if this User Object has changed, it is instantiated. The Reorder function allows to reorder the Knowledge Patterns.