I found a way to (sort of) select the welding symbols. It's an ugly hack but it works. The preselect event recognises the "DrawingWeldSymbol". I expect that it's a bug that it isn't recognised by the select event. You can work around this by saving the preselected object in a property and wait for the select interaction to end. This can be done like this: User clicks on the weld symbol and presses "esc" key. (What do you think about it?)

Public Class ThisRule
Public Sub main()
Dim selector As New Selector(ThisApplication)
selector.Pick()
Dim weldSymbol As DrawingWeldingSymbol = selector.SelectedObject
MsgBox(weldSymbol.Definitions.Item(1).TailNote)
End Sub
End Class
Public Class Selector
Private WithEvents _interactEvents As InteractionEvents
Private WithEvents _selectEvents As SelectEvents
Private _stillSelecting As Boolean
Private _inventor As Inventor.Application
Public Sub New(ThisApplication As Inventor.Application)
_inventor = ThisApplication
End Sub
Public Sub Pick()
_stillSelecting = True
_interactEvents = _inventor.CommandManager.CreateInteractionEvents
_interactEvents.InteractionDisabled = False
_interactEvents.StatusBarText = MousePointerText
' ^-- This will also set the mousepointer text
_interactEvents.SetCursor(CursorType)
_selectEvents = _interactEvents.SelectEvents
_selectEvents.WindowSelectEnabled = False
_interactEvents.Start()
Do While _stillSelecting
_inventor.UserInterfaceManager.DoEvents()
Loop
_interactEvents.Stop()
_inventor.CommandManager.StopActiveCommand()
End Sub
Public Property SelectedObject As DrawingWeldingSymbol = Nothing
Public Property MousePointerText As String = "Select ..."
Public Property CursorType As CursorTypeEnum = CursorTypeEnum.kCursorTypeDefault
Public Property Filter As ObjectTypeEnum = Nothing
Private Sub selectEvents_OnStopPreSelect(ModelPosition As Point, ViewPosition As Point2d, View As View) Handles _selectEvents.OnStopPreSelect
_interactEvents.StatusBarText = "..."
End Sub
Private Sub selectEvents_OnPreSelect(
ByRef PreSelectEntity As Object,
ByRef DoHighlight As Boolean,
ByRef MorePreSelectEntities As ObjectCollection,
SelectionDevice As SelectionDeviceEnum,
ModelPosition As Inventor.Point,
ViewPosition As Point2d,
View As Inventor.View) Handles _selectEvents.OnPreSelect
DoHighlight = False
_interactEvents.StatusBarText = Microsoft.VisualBasic.Information.TypeName(PreSelectEntity)
If (TypeOf PreSelectEntity Is DrawingWeldingSymbol) Then
_interactEvents.StatusBarText = "DrawingWeldingSymbol has been found!!! (press escape to continue.)"
SelectedObject = PreSelectEntity
DoHighlight = True
End If
End Sub
Private Sub selectEvents_OnSelect(
ByVal JustSelectedEntities As ObjectsEnumerator,
ByVal SelectionDevice As SelectionDeviceEnum,
ByVal ModelPosition As Inventor.Point,
ByVal ViewPosition As Point2d,
ByVal View As Inventor.View) Handles _selectEvents.OnSelect
SelectedObject = JustSelectedEntities
_stillSelecting = False
End Sub
Private Sub interactEvents_OnTerminate() Handles _interactEvents.OnTerminate
_stillSelecting = False
End Sub
End Class
Jelte de Jong
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.

Blog: hjalte.nl - github.com