Creating a Knowledge Advisor
Reaction: Instantiation Event
|
This task explains how to use a reaction
in a User Defined Feature.
The scenario described below is divided into two major steps:
| In the first step, you first create a formula that returns the
length of the line, you create a reaction that will add items of
length type to a list when the document is instantiated and then
you create a UDF containing the line, the reaction and the formula. |
| In the second step, you open a second document, you create a rule
based on a list that will display the total length, and then you
instantiate the UDF that you previously created in this document. |
|
|
A basic understanding of the Part Design
workbench and of Product Knowledge Template is required to carry out this scenario. |
|
-
Open the KwrUDFandReaction.CATPart
file.
-
Create a parameter of Length type and assign it
a formula. To do so, proceed as follows:
|
Click the
icon, select Length in the New Parameter of
Type scrolling list, click the New Parameter of type
button, and click the Add Formula button. |
|
In the Dictionary, select Measures, and
length
(Curve, …): Length. |
|
Position the cursor between
the parentheses and double-click Line.1 in the specification tree.
Click OK, Yes, and OK. (Length.1=length(Open_body.1\Line.1)).
|
3. Access the Knowledge Advisor
workbench, click the List icon ()
to create a list, and click OK. An empty list appears under the Parameters
node.
(Click the graphic opposite to enlarge it.) |
|
-
Click the Reaction ()
icon. The Reaction editor opens:
|
In the Source type list, select Owner. |
|
In the Available events,
select Instantiation. |
|
In the Action area, select Knowledgeware
action and click the Edit action...
button. The Action editor opens. |
|
Click the list in the specification tree and,
in the Dictionary pane select List, and in the Member pane, select List.AddItem. |
|
Position the cursor between the parentheses
and enter Length.1 before the comma, and 0 after the coma.
Click OK twice. The Reaction feature is created. |
-
Access the Part Design workbench and select the
Insert->UserFeature->UserFeature creation … command.
The Userfeature Definition window opens: in the Definition tab,
enter the name of the User Feature (UserFeature1 in this scenario)
and select the Line, the Reaction, and the Length parameter in the
specification tree. Click OK.
The UserFeature1 is created and displayed under the Knowledge
Templates node.
-
Save your file, close it, and open the KwrUDFandReaction2.CATPart
file This is the file into which you will instantiate the UDF you
previously created.
-
Access the Knowledge Advisor workbench, and
click the list icon ()
to create an empty list and click OK.
-
Create a parameter of Length type
(called Length.1 in this scenario) and apply
a formula to it. To do so, proceed as follows:
|
Click the
icon, select Length in the
scrolling list, click the New Parameter of type
button, and click the Add Formula button. |
|
Select the list in the specification tree, in
the Dictionary pane select List, and in the Member pane, select List.sum. Click
OK three times. |
-
Click the Rule icon (), click OK, enter the
following script in the Rule Editor, and click OK:
Message("Total Length
: #",Length.1 ) |
The total length is displayed: 0mm.
-
Access the Part Design workbench and select the
Insert->Instantiate
from Document … command.
-
Select the file you created (from step 1 to
step 5, KwrUDFandReaction.CATPart in this scenario) and click Open. The
Insert Object window opens:
|
Select Point.1 in the specification tree or in
the geometry. |
|
Select Point.2 in the specification tree or in
the geometry. |
|
Select List.1 in the specification tree and
click OK. |
The rule is fired and the Total
Length is displayed. |
|
|
|