Creating a Knowledge Advisor
Reaction: DragAndDrop Event
|
This task explains how to use the DragAndDrop
event in a reaction
feature. In the scenario below, the user drags and drops a hole, which
fires a reaction.
a) The following information are displayed in a VB box when the rule
is fired:
| The type of feature. |
| Its name as well as its initial diameter. |
b) The user is prompted to click OK to convert the hole
into a counterbored one or to click Cancel to skip the
conversion. |
|
The Reaction capabilities require the Knowledge Advisor product. |
|
Note that this task could be carried out in
the past by using the Behavior feature which has been replaced with the
Reaction feature.
For
more information about Reaction features, see Working
with the Reaction Feature.
|
|
- Create a pad with a hole or open the KwrReactionPad.CATPart
file.
- Access the Knowledge Advisor workbench and click the Reaction icon
()
to create a reaction. The reaction dialog box opens.
|
| In the Source type field, select Owner
for the Reaction to be applied to the hole selected in
the Destination area (see below). |
|
| In the Available events list, select DragAndDrop
for the reaction to occur when the hole is dragged and
dropped. |
|
| In the Action field, select VB action,
for the user to write the action in VB. |
|
| Click the Destination area in the Reaction
dialog box and select Hole.1 in the specification tree. |
|
- Click the Edit Action... button, paste the
following script in the editor, and click OK twice:
Set
H = DroppedFeature.Parent.Item(DroppedFeature.Name)
Dim FeatureType, FeatureName, HoleType
FeatureType = TypeName(H)
FeatureName = H.Name
HoleType = H.Type
Str1 = "The feature to be dropped"
Str2 = Str1 & vbCrLf & "is a " &
FeatureType & " type feature"
Str3 = Str2 & vbCrLf & "Its name is '" &
FeatureName & "'"
Str4 = Str3 & vbCrLf & "Its initial diameter is
"_
& H.Diameter.Value & vbCrLf
Str5=Str4 & vbCrLf &_
"Unless you click Cancel, it will be converted into a
counterbored hole"
Dim MyBox
MyBox = MsgBox (Str5,1)
if MyBox = 1 then
H.Type = 2
H.HeadDiameter.Value = 20.0
H.Diameter.Value = 10.0
End If |
- Access the Part Design workbench. In the geometry, select the hole and drag and drop
it. The following dialog box appears:
- Click OK. The hole is converted into a counterbored
hole (see graphic below).
|
|
To know more about the Reaction feature
window, see Using
the Reaction Feature Window. |
|