Hi @gopinathmY575P . Try the solution from Mr. @JhoelForshav . Found in the next topic.
Sub Main
Dim oSelect As New clsSelect
oSelect.WindowSelect(ThisApplication)
MsgBox(oSelect.SelectedObjects.Count)
End Sub
Class clsSelect
Private WithEvents oInteractEvents As InteractionEvents
Private WithEvents oSelectEvents As SelectEvents
Private bTooltipEnabled As Boolean
Private ThisApplication As Inventor.Application
Public SelectedObjects As ObjectsEnumerator
Private stillSelecting As Boolean = True
Public Sub WindowSelect(oApp As Inventor.Application)
ThisApplication = oApp
oInteractEvents = ThisApplication.CommandManager.CreateInteractionEvents
oInteractEvents.InteractionDisabled = False
oSelectEvents = oInteractEvents.SelectEvents
oSelectEvents.AddSelectionFilter(SelectionFilterEnum.kAssemblyLeafOccurrenceFilter)
oSelectEvents.WindowSelectEnabled = True
bTooltipEnabled = ThisApplication.GeneralOptions.ShowCommandPromptTooltips
ThisApplication.GeneralOptions.ShowCommandPromptTooltips = True
oInteractEvents.StatusBarText = "Select component occurrences. Esc to finish."
oInteractEvents.Start()
While stillSelecting
ThisApplication.UserInterfaceManager.DoEvents()
End While
End Sub
Private Sub oInteractEvents_OnTerminate() Handles oInteractEvents.OnTerminate
ThisApplication.GeneralOptions.ShowCommandPromptTooltips = bTooltipEnabled
oSelectEvents = Nothing
oInteractEvents = Nothing
stillSelecting = False
End Sub
Private Sub oSelectEvents_OnSelect(ByVal JustSelectedEntities As ObjectsEnumerator, ByVal SelectionDevice As SelectionDeviceEnum, ByVal ModelPosition As Point, ByVal ViewPosition As Point2d, ByVal View As View) Handles oSelectEvents.OnSelect
SelectedObjects = oSelectEvents.SelectedEntities
End Sub
Private Sub oSelectEvents_OnUnSelect(UnSelectedEntities As ObjectsEnumerator, SelectionDevice As SelectionDeviceEnum, ModelPosition As Point, ViewPosition As Point2d, View As View) Handles oSelectEvents.OnUnSelect
SelectedObjects = oSelectEvents.SelectedEntities
End Sub
End Class
Additionally, you can use the SelectSet method to get all selected objects.