- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm writing an add-in tool that I would like to watch the OnPreSelect event, and when a certain entity is hovered over, I'd like it to replace Inventor's pre-selection with a different one.
In other words...
Sorry, couldn't resist 😉
Anyway, this is the code I'm using to experiment with doing this:
Sub UserInputEvents_OnPreSelect(ByRef PreSelectEntity As Object, ByRef DoHighlight As Boolean, ByRef MorePreSelectEntities As ObjectCollection, SelectionDevice As SelectionDeviceEnum, ModelPosition As Point, ViewPosition As Point2d, View As View) Handles inputEvents.OnPreSelect If SelectionDevice = SelectionDeviceEnum.kGraphicsWindowSelection Then If TypeOf PreSelectEntity Is OccurrencePattern Then Dim patt As OccurrencePattern = DirectCast(PreSelectEntity, OccurrencePattern) Console.WriteLine($"Changing pre-select entity for pattern {patt.Name}...") PreSelectEntity = patt.OccurrencePatternElements.Item(1) Console.WriteLine("Pre-select entity changed.") End If End If End Sub
When I hover over a component pattern in an assembly, it should remove the full pattern from the pre-selection and only pre-select the first entity of the pattern. However, it doesn't do either of those things.
The console writes do get written, so it definitely is handling the event and executing the assignment to PreSelectEntity, but it doesn't seem to have any effect.
What am I doing wrong? Is there another way I should be doing this?
Solved! Go to Solution.