Error : Event OnMouseClick cannot be found

ktelangCGFU6
Participant
Participant

Error : Event OnMouseClick cannot be found

ktelangCGFU6
Participant
Participant

Hi Everyone, 

I am trying to get the drawing clicked point to Point2D. The code was original posted by @ekinsb in some previous post for VBA. I am using the same and modifying it in VB.net. For some reason the OnMouseClick is cannot be found.

 

The m_mouse shows only Activate, Suspend, Terminate, Help events 

 

Public Class Cls_GetDwgPickPoint
    Private WithEvents m_interaction As Inventor.InteractionEvents
    Private WithEvents m_mouse As InteractionEvents
    Private m_position As Point2d
    Private m_button As MouseButtonEnum
    Private m_continue As Boolean

    Public Sub New()

    End Sub

    Public Function GetDrawingPoint(Prompt As String, button As MouseButtonEnum) As Point2d
        m_position = Nothing
        m_button = button

        ' Start selection.
        m_interaction = g_inventorApplication.CommandManager.CreateInteractionEvents
        m_mouse = m_interaction.MouseEvents

        m_interaction.StatusBarText = Prompt
        m_interaction.Start()

        Do While m_continue
            g_inventorApplication.UserInterfaceManager.DoEvents()
        Loop


        m_interaction.Stop()
        GetDrawingPoint = m_position
        Return GetDrawingPoint

        'Debug.Print("GetDrawingPoint: " & GetDrawingPoint.X & "," & GetDrawingPoint.Y)

    End Function

    Public Sub m_mouse_OnMouseClick(Button As MouseButtonEnum, ShiftKeys As ShiftStateEnum, ModelPosition As Point, ViewPosition As Point2d, View As View) Handles m_mouse.OnMouseClick
        If Button = m_button Then
            m_position = g_inventorApplication.TransientGeometry.CreatePoint2d(ModelPosition.X, ModelPosition.Y)
            Debug.Print(m_position.X & "," & m_position.Y)
        End If

        m_continue = False
        ' MsgBox("Mouse clicked: " & m_position.X & "," & m_position.Y)
    End Sub

    Private Sub m_interaction_OnTerminate() Handles m_interaction.OnTerminate
        m_continue = False
        m_interaction.Stop()
    End Sub

    Private Sub m_interaction_OnActivate() Handles m_interaction.OnActivate
        m_continue = True

    End Sub

End Class

 

0 Likes
Reply
Accepted solutions (1)
172 Views
1 Reply
Reply (1)

ktelangCGFU6
Participant
Participant
Accepted solution

I did mistake while converting from VBA to Vb.net

 

Line with mistake

 

Private WithEvents m_mouse As InteractionEvents

 

 

 

Below is correct code

 

 

Private WithEvents m_mouse As Inventor.MouseEvents

 

 

0 Likes