Automation |
Knowledge Expert Principles |
This article provides the basis for understanding how to create macros
replaying most of the operations you can perform with the Knowledge Expert
product. Note that the Knowledge Expert product does not provide you with
journaling capabilities. The objects described below as well as the Use Cases
which illustrate how to manipulate these objects can only be used to write a VB
macro to be replayed later on. None of the Knowledge Expert operations that you
can perform interactively can be recorded in a script by using the
Basically, to start with Knowledge Expert automation, you need know:
how to create the Knowledge Expert objects you are going to manipulate. These objects are the document rule base, the rule sets, the expert rules and the expert checks. They are all Relation objects that you create from the Relations collection.
how to manipulate these objects.
how to launch some Knowledge Expert specific operations such as Solving a rule base, generating a check report or highlighting the elements that don't fulfill the criteria specified in a check.
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
Knowledge Expert objects.
The entry point is the Relations collection which provides you with the CreateRuleBase method. This method takes as its argument the rule base name.
Dim oRel As Relations Set oRel = oActiveDoc.Part.Relations ' Create the RB1 rulebase Dim oRuleBase As Relation Set oRuleBase = oRel.CreateRuleBase("RB1") |
You can create a rule base below the Relations node of a CATProduct.
Dim oRel As Relations Set oRel = oActiveDoc.Product.Relations ' Create the RB1 rulebase Dim oRuleBase As Relation Set oRuleBase = oRel.CreateRuleBase("RB1") |
After a rule base has just been created, it is in a to-be-solved status.
In interactive mode, you don't have to create rule sets. They are automatically created upon creation of rules and checks. It is the same in VB.
In the present version, rule sets cannot be gathered in a collection. There are no direct means to retrieve the set of RuleSet objects.
Prior to using the rule or check creation methods, you need retrieve the RuleSet object from the rule base. To create an expert rule/check, you must specify the rule set name as the last argument of the CreateCheck or CreateRule method. In the statements below, RuleSet.1 is created if it does not exist yet. If it is already existing the HDiaCheck is created right below it.
Dim oCheck As Relation Set oCheck= oRuleBase.RuleSet.CreateCheck("HDiaCheck","H:Hole","H.Diameter>12mm","RuleSet.1") |
The status of a rule base is described by its FingerPrint attribute. If it is set to 0, the rule base must be solved, if it is set to 1, the rule base is solved.
The experts rules and checks making up a rule base are grouped into an ExpertRuleBaseComponentRunTimes collection. The component type where by you can differentiate a rule from a check in a collection is ExpertCheckRunTime or ExpertRuleRunTime.
To solve a rule base, use the rulebase.Deduce() method.
To generate a report, use the rulebase.Report() method
To highlight the elements which do not satisfy the checks, use the rulebase.Highlight() method.
[Top]
Copyright © 1994-2004, Dassault Systèmes. All rights reserved.