Capturing click events and points during a native command (Leader)

Capturing click events and points during a native command (Leader)

NachoShaw
Advisor Advisor
251 Views
3 Replies
Message 1 of 4

Capturing click events and points during a native command (Leader)

NachoShaw
Advisor
Advisor

Hi

 

im curious. Is there a way to add a listener that can capture the click events which in turn can capture point locations during a native command? For easiness i'll reference the leader-

  • Invoke the native leader command from a code function that will allow to the listener to fire
  • continue with the native leader points being clicked and text being added
  • leader closes, listener stops
  • provide points clicked back to the user

 

Thanks

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


0 Likes
252 Views
3 Replies
Replies (3)
Message 2 of 4

Frederick_Law
Mentor
Mentor

Typically the event listener will listen to all click events and filter out event from Leader Command.

 

To turn it on and off will need another event listener which catch Command event.

0 Likes
Message 3 of 4

Michael.Navara
Advisor
Advisor

This s not possible, because only one instance of interaction events can be active at the time. Command DrawingLeaderTextCmd starts its own interaction events and your terminates.

 

You can play with the following code to get more information about interaction events behavior. Comment/uncomment lines in Sub Main for testing different scenarios. 

 

Sub Main()

    interactionEvts = ThisApplication.CommandManager.CreateInteractionEvents()
    mouseEvts = interactionEvts.MouseEvents

    AddHandler mouseEvts.OnMouseClick, AddressOf OnMouseClick
    AddHandler interactionEvts.OnTerminate, AddressOf OnTerminate
    AddHandler interactionEvts.OnActivate, AddressOf OnActivate
    AddHandler interactionEvts.OnHelp, AddressOf OnHelp
    AddHandler interactionEvts.OnSuspend, AddressOf OnSuspend
    AddHandler interactionEvts.OnResume, AddressOf OnResume

    SharedVariable.Value("intEvents") = interactionEvts


    'interactionEvts.Start()

    Logger.Debug("Start command")

    'Start command terminates current interaction events

    'Waits until the command ends
    'interactionEvts.Parent.ControlDefinitions.Item("DrawingLeaderTextCmd").Execute2(true)

    'Continue execution
    'interactionEvts.Parent.ControlDefinitions.Item("DrawingLeaderTextCmd").Execute()

    Logger.Debug("End command")

    'Start interaction events terminates current command
    interactionEvts.Start()

End Sub

Dim interactionEvts As InteractionEvents
Dim mouseEvts As MouseEvents

Private Sub OnResume()
    LogEvent()
End Sub

Private Sub OnSuspend()
    LogEvent()
End Sub

Private Sub OnHelp(beforeorafter As EventTimingEnum, context As NameValueMap, ByRef handlingcode As HandlingCodeEnum)
    LogEvent()
End Sub

Private Sub OnActivate()
    LogEvent()
End Sub

Private Sub OnTerminate()
    LogEvent()
End Sub

Private Sub OnMouseClick(button As MouseButtonEnum, shiftKeys As ShiftStateEnum, modelPosition As Point, viewPosition As Point2d, view As Inventor.View)
    LogEvent()
End Sub

Private Sub LogEvent(<System.Runtime.CompilerServices.CallerMemberNameAttribute> Optional caller As String = "")
    Logger.Debug(caller)
End Sub

 

0 Likes
Message 4 of 4

Michael.Navara
Advisor
Advisor
In the special case, you can obtain the points of created leader from its properties.
0 Likes