- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm struggling with monitoring Revit for element selection changes.
Window selections are no problem; monitoring element selection changes as a user "Control Picks" them is the main issue im working on a solution for. Way back Revit apparently had a "Element Selection Changed" Method but its been hidden/deprecated to the dismay of many in our community.
Because of this many in our community have come up with some great ideas to solve this seemingly rudimentary issue.
Specifically, detailed on Jeremy Tammicks awesome site The Building Coder, is this post which lays out the three most viable workarounds.
- Use the OnIdling event to check current selection
- Use a Timer to raise an event at a specified interval.
- Use Revit's Modify Tab PropertyChanged Event to return a list of selected elements.
The one ive tried to implement is #3 which was originally suggested by a member of our community named Vilo here. Jeremy Tammick has made this code available for our use in the SDK Samples. Here is the repository of the current "working state" of my implementation.
Jeremy had great suggestions as usual but the issues below remain.
- The "PropertyChanged" event continues to fire after Unsubscribing to the event.
- Element Ids are reported multiple times based on how many times the event is Subscribed/Un-Subscribed. See Screenshot #1 (Probably ties into item #1 Event still fires. Another thought i had was does the "PropertyChanged" get fired again because of a resulting PropertyChange from the initial "PropertyChanged" event?
- Not all ElementIds are reported as they are selected. Hunch is that there is not property change at some point. Once a dissimilar Element is selected causing a property change the event fires and all of the Element Ids are shown.
If you've found a solution to the main problem of "Element Selection Changed Monitoring" or to the implementation of Vilo's suggestion to subscribe to the Modify Tabs property changed event i, and i suspect many other, would appreciate some feedback.
Solved! Go to Solution.