- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, experts,
In an assembly, you can simply click on a part and hold the click and drag it around, as below picture.
I would like to listen this event and catch the final position of the part when the drag stops (when you release the hold on the mouse). I use the following code. It is able to catch the drag operation when it starts. But it is unable to catch the event of end of drag. I was using DragStateEnum.kDragStateEndDrag to try to listen to the end of drag, but NO success. There are a couple of status in DragStateEnum Enumerator, only kDragStateDragHandlerSelection has response, all the others have NOT response.
Is it a bug? Does anyone know why and help?
Sub drag_component()
Set oDrag_comp = New clsDrag
Call oDrag_comp.Class_Initialize
End Sub
'--------Put below to a class of VBA, giving a name "clsDrag"
Option Explicit
Private WithEvents oUIEvents As UserInputEvents
Public Sub Class_Initialize()
Set oUIEvents = ThisApplication.CommandManager.UserInputEvents
End Sub
Private Sub oUIEvents_OnDrag(ByVal DragState As DragStateEnum, ByVal ShiftKeys As ShiftStateEnum, _
ByVal ModelPosition As Point, ByVal ViewPosition As Point2d, ByVal View As View, _
ByVal AdditionalInfo As NameValueMap, HandlingCode As HandlingCodeEnum)
'this responds
MsgBox ("start drag 1")
'this responds
If DragState = kDragStateDragHandlerSelection Then
MsgBox ("start drag 2")
End If
'This has NOT response
If DragState = kDragStateEndDrag Then
MsgBox ("start drag 3")
End If
End Sub
Limin
Inventor pro 2023 64 bit update 5.3; Windows 11 pro 64 bit version 24H2; Office 2013 64 bit
Solved! Go to Solution.