OnSelect event help

OnSelect event help

Anonymous
Not applicable
682 Views
2 Replies
Message 1 of 3

OnSelect event help

Anonymous
Not applicable

Here is the code i have  so far. I want to select an object and see the type of the selected object and then remove the handler. Any help with this code???

 

 

Class TestShared
Shared WithEvents oUIEvents As UserInputEvents

Sub main

oUIEvents = ThisApplication.CommandManager.UserInputEvents

AddHandler oUIEvents.OnSelect, AddressOf oUIEvents_OnSelect

End Sub

Sub oUIEvents_OnSelect(JustSelectedEntities As ObjectsEnumerator, MoreSelectedEntities As ObjectCollection, SelectionDevice As SelectionDeviceEnum, ModelPosition As Point, ViewPosition As Point2d, View As Iventor.View )

	MessageBox.Show(JustSelectedEntities.Type)

	'RemoveHandler oUIEvents.OnSelect, AddressOf oUIEvents_OnSelect
	oUIEvents = Nothing
	
End Sub

End Class

 

0 Likes
Accepted solutions (2)
683 Views
2 Replies
Replies (2)
Message 2 of 3

frederic.vandenplas
Collaborator
Collaborator
Accepted solution

Hi, This one triggers the event and removes the handler after the first click.

I hope you add your needs to this example!

if found my inspirarion here... 

Imports Inventor

	
Public Class SelectEventHanlder1
	
Private _interactionEvents As Inventor.InteractionEvents
Private _selectEvents As Inventor.SelectEvents
 
 Sub main
	 
_interactionEvents = ThisApplication.CommandManager.CreateInteractionEvents()
_selectEvents = _interactionEvents.SelectEvents

AddHandler _selectEvents.OnSelect, AddressOf SelectEvents_OnSelect

_interactionEvents.Start()
	 
End Sub

 
 Public Sub SelectEvents_OnSelect(ByVal JustSelectedEntities As Inventor.ObjectsEnumerator, ByVal SelectionDevice As Inventor.SelectionDeviceEnum, ByVal ModelPosition As Inventor.Point, ByVal ViewPosition As Inventor.Point2d, ByVal View As Inventor.View)
  
  MessageBox.Show(JustSelectedEntities.Item(1).ToString)
RemoveHandler _selectEvents.OnSelect, AddressOf SelectEvents_OnSelect
	_interactionEvents = Nothing
 End Sub
 
End Class
If you think this answer fullfilled your needs, improved your knowledge or leads to a solution,
please feel free to "kudos"
0 Likes
Message 3 of 3

Anonymous
Not applicable
Accepted solution

frederic.vandenplas thanc for the help. I use ilogic so this is my final code for selecting

 

	
Class SelectEventHanlder1
	
Shared WithEvents _interactionEvents As InteractionEvents
Shared WithEvents _selectEvents As SelectEvents
 
 Sub Main
	 
_interactionEvents = ThisApplication.CommandManager.CreateInteractionEvents()
_selectEvents = _interactionEvents.SelectEvents

AddHandler _selectEvents.OnSelect, AddressOf SelectEvents_OnSelect

_interactionEvents.Start()
	 
End Sub

 
 Sub SelectEvents_OnSelect(ByVal JustSelectedEntities As Inventor.ObjectsEnumerator, ByVal SelectionDevice As Inventor.SelectionDeviceEnum, ByVal ModelPosition As Inventor.Point, ByVal ViewPosition As Inventor.Point2d, ByVal View As Inventor.View)
  
 MessageBox.Show(JustSelectedEntities.Item(1).ToString)
 _interactionEvents.Stop() 
RemoveHandler _selectEvents.OnSelect, AddressOf SelectEvents_OnSelect
_interactionEvents = Nothing
End Sub
 
End Class