The VBA version was working for me. You may not have set it up correctly, if its not working for you. Setting it up within the VBA Editor can be a bit odd/unexpected if your not used to using the 'Class Modules'. So, I put pretty much all my VBA Macros within a custom application project that all users have access to on a shared drive. Under the application project, in the tree view, you have three folders ("Forms", "Modules", & "Class Modules"). The first part of the code in that sample should be put into a regular Module by itself, and called "TestWindowSelection". That regular module will only contain the first Private oSelect As clsSelect line, and the first Sub TestWindowSelection() block of code.
Private oSelect As clsSelect
Public Sub TestWindowSelection()
' Create a new clsSelect object.
Set oSelect = New clsSelect
' Call the WindowSelect method of the clsSelect object
oSelect.WindowSelect
End Sub
All the rest of the code below that point (blue comment block, Private WithEvents, and so on) should be put into a new 'Class Module' by itself, under the folder called "Class Modules", and that Class Module should be named "clsSelect" (important).
'*************************************************************
' The declarations and functions below need to be copied into
' a class module whose name is "clsSelect". The name can be
' changed but you'll need to change the declaration in the
' calling function "TestWindowSelection" to use the new name.
' Declare the event objects
Private WithEvents oInteractEvents As InteractionEvents
Private WithEvents oSelectEvents As SelectEvents
' Declare a flag that's used to determine if command prompts are shown as tooltips.
Private bTooltipEnabled As Boolean
Public Function WindowSelect()
' Create an InteractionEvents object.
Set oInteractEvents = ThisApplication.CommandManager.CreateInteractionEvents
' Ensure interaction is enabled.
oInteractEvents.InteractionDisabled = False
' Set a reference to the select events.
Set oSelectEvents = oInteractEvents.SelectEvents
' Set the filter for circular edges (this includes circular arcs).
oSelectEvents.AddSelectionFilter kPartEdgeCircularFilter
oSelectEvents.WindowSelectEnabled = True
bTooltipEnabled = ThisApplication.GeneralOptions.ShowCommandPromptTooltips
ThisApplication.GeneralOptions.ShowCommandPromptTooltips = True
oInteractEvents.StatusBarText = "Window select. Esc to exit."
' Start the InteractionEvents object.
oInteractEvents.Start
End Function
Private Sub oInteractEvents_OnTerminate()
' Reset to original value
ThisApplication.GeneralOptions.ShowCommandPromptTooltips = bTooltipEnabled
' Clean up.
Set oSelectEvents = Nothing
Set oInteractEvents = Nothing
End Sub
Private Sub oSelectEvents_OnPreSelect(PreSelectEntity As Object, DoHighlight As Boolean, MorePreSelectEntities As ObjectCollection, ByVal SelectionDevice As SelectionDeviceEnum, ByVal ModelPosition As Point, ByVal ViewPosition As Point2d, ByVal View As View)
' Set a reference to the selected edge.
' Only circular edges can come through since the circular edge filter was set.
Dim oEdge As Edge
Set oEdge = PreSelectEntity
' Allow only fully circular edges to be picked.
If Not oEdge.GeometryType = kCircleCurve Then
DoHighlight = False
End If
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)
MsgBox "Picked " & JustSelectedEntities.Count & " circular edges."
End Sub
Then within the regular Module, when it creates a new instance of that class for the variable oSelect, it accesses the class module that corresponds to that class' name to for all the information about it. Very different and awkward setting it up this way, when you're used to working with iLogic and vb.net for a long time.
If you already had it all set-up correctly, and it still isn't working, maybe there's something within the code that doesn't work with your specific version of Inventor, I'm not sure.
Wesley Crihfield

(Not an Autodesk Employee)