Creating a Knowledge Advisor
Reaction: DragAndDrop Event
![](../icons_C2/common/atarget.gif) |
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:
![](_themes/v5r5/ul1.gif) | The type of feature. |
![](_themes/v5r5/ul1.gif) | 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. |
![](../icons_C2/common/awarning.gif) |
The Reaction capabilities require the Knowledge Advisor product. |
![](../icons_C2/common/ainfo.gif) |
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.
|
![](../icons_C2/common/ascenari.gif) |
- 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.
![](images/kwrReactionDialogBox1NLS.gif) |
![](_themes/v5r5/ul1.gif) | In the Source type field, select Owner
for the Reaction to be applied to the hole selected in
the Destination area (see below). |
|
![](_themes/v5r5/ul1.gif) | In the Available events list, select DragAndDrop
for the reaction to occur when the hole is dragged and
dropped. |
|
![](_themes/v5r5/ul1.gif) | In the Action field, select VB action,
for the user to write the action in VB. |
|
![](_themes/v5r5/ul1.gif) | 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:
![](images/kwrReactionVBScriptMessageBoxNLS.gif)
- Click OK. The hole is converted into a counterbored
hole (see graphic below).
![](images/kwrReactionResultNLS.gif)
|
![](../icons_C2/common/ainfo.gif) |
To know more about the Reaction feature
window, see Using
the Reaction Feature Window. |
|