|
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.
|
|
|
-
Open the
KwrUDFandReaction.CATPart file.
-
Create a parameter of Length type and assign
it a formula.
- Click the
icon, select Length from the New Parameter of Type
scrolling list, click New Parameter of type, and click
Add Formula.
|
- In the Dictionary, click Measures, and
double-click 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(Geometrical Set.1\Line.1)).
|
-
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 Reaction ()
icon. The Reaction editor opens:
|
|
|
-
Click the list in the specification tree and, in
the Dictionary pane select List, and in the Member pane,
double-click List.AddItem.
|
|
-
Access the Part Design workbench and select Insert >
UserFeature > UserFeature creation. 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.
-
Click the
icon, select Length from the scrolling list, click
New Parameter of type, and click Add Formula.
|
-
Select the list in the specification tree, in the
Dictionary pane select List, and in the Member pane, double-click
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 Insert >
Instantiate from Document.
-
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.
|
|