Automation |
Knowledge Advisor Overview |
This article provides the basis for understanding how to create macros using
knowledgeware features. These
knowledgeware features are supplied in the Infrastructure product (parameters,
formulas and design tables) as
well as in the Knowledge Advisor product (rules and checks).
The CATIA Knowledge Advisor automation objects are those whereby you can create and manipulate the knowledgeware features in a script. These automation objects can be divided into two categories:
The objects which provide you with the creation methods. They are the Relations and Parameters collections. These objects are only implemented on CATPart documents.
The knowledgeware objects whereby you can manipulate the Parameter, Formula, Rule, Check and Design Table features once they have been created. The hierarchy of these objects is described in the Parameter and Relation tree structures.
The Use Cases provided as samples are fully commented and should help you
understand how to
proceed to write simple macros as well as fully-fledged macros manipulating
knowledgeware features.
The entry point is the Relations or Parameters collection. To retrieve the appropriate collection, you must: retrieve the Part object of the active document. This Part object aggregates all the objects making up the CATPart: the Bodies, the Relations, the Parameters to name but a few. Mull over the Part properties, they all provide you with collections or factories to create objects.
You can retrieve a Parameters object that way:
Dim oActiveDoc As Document Set oActiveDoc = CATIA.ActiveDocument Dim oParams As Parameters Set oParams = oActiveDoc.Part.Parameters
but prior to writing this, you must check that your document is a CATPart.
To create the object, you just have to use the appropriate Createxxx method.
Dim oSphereRadius As Parameter Set oSphereRadius = oParameters.CreateInteger("StringLength",0)
Parameters as well as Relations can be scanned in their collections. An item is retrieved from its collection using the Item method and the index of the item in the collection. Usually, the argument representing the index in the Item method is a Variant. This means that it can either represent the rank of the item in the collection or the name you assigned to this item using the Name property. The rank in a collection begins at 1. For example, assume that the Parameter named "StringLength" is the sixth parameter in the Parameters collection. To retrieve this parameter in the oParameters collection, write:
Dim oParam1 As Parameter Set oParam1 = oParams.Item(6)
or write:
Dim oParam1 As Parameter Set oParam1 = oParams.Name("StringLength")
Each collection has a Count property that holds the number of items in the collection. This is a handy property to scan the whole collection.
Warning
When counting the items in a Parameters collection, mind that you count all the document parameters and not only the user parameters.
After they have been created, knowledgeware objects are managed through their properties and methods. To find out what they are, see the Knowledge Advisor Automation API Reference.
[Top]
Copyright © 1994-2004, Dassault Systèmes. All rights reserved.