Creating a Reaction: DragAndDrop Event  

This task explains how to use the DragAndDrop event in a reaction feature. In the scenario below, you are going to drag and drop 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) You are prompted to click OK to convert the hole into a counterbored one or to click Cancel to skip the conversion.

Note that this task was performed 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.

  1. Create .CATPart file and a pad with a hole or open the KwrReactionPad.CATPart file.

  2. 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).

    • From 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, to write the action in VB.

    • Click the Destination area in the Reaction dialog box and select Hole.1 in the specification tree.

  3. Click Edit Action..., 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
  1. Access the Part Design workbench. In the geometry, select the hole and drag and drop it. The following dialog box appears:

  1. Click OK. The hole is converted into a counterbored hole (see graphic below).

 For more information about the Reaction feature window, see Using the Reaction Feature Window.