kAssemblyOccurrenceFilter - Select Multiple occurence

kAssemblyOccurrenceFilter - Select Multiple occurence

gopinathmY575P
Advocate Advocate
175 Views
2 Replies
Message 1 of 3

kAssemblyOccurrenceFilter - Select Multiple occurence

gopinathmY575P
Advocate
Advocate

Dim oPar

Set oPar = ThisApplication.CommandManager.Pick(kAssemblyOccurrenceFilter, "Select occurence") 

 

i want to pick more than 1 occurrence as a collection, maximum of 5 occurrence.

0 Likes
176 Views
2 Replies
Replies (2)
Message 2 of 3

Andrii_Humeniuk
Advisor
Advisor

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.

Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor

LinkedIn | My free Inventor Addin | My Repositories

Did you find this reply helpful ? If so please use the Accept as Solution/Like.

EESignature

0 Likes
Message 3 of 3

gopinathmY575P
Advocate
Advocate

Hi, @Andrii_Humeniuk thanks for idea and quick reply, is that same example working in vba?

 

0 Likes