Element Selection Changed Event - Implementation Struggles - revit-api

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 Tammick 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.

Fair69 on the Autodesk Revit API forum had the best workaround the overall issue of selection monitoring. See Answer: https://forums.autodesk.com/t5/revit-api-forum/element-selection-changed-event-implementation-struggles/m-p/9237464/highlight/true#M43721

Related

Is there IndexChanged event for grid in Acumatica

Acumatica has plenty of events for views like Row_Updated, Field_Updated. I search for something like Index_Changed event but for now I can't find. Does it have some other name or exists at all?
There's no row selected index changed event that will bubble up to the graph. Instead there's a bunch of mechanisms designed to solve a narrow problem that would have required that missing event, these are the likes of DependOnGrid, StateColumn, AutoCallback/Refresh, Sync Position etc.
The reasoning behind this design could be to reduce the number of callbacks from the webpage to the server. From the user point of view, changing row selection is not a transactional operation. Having the webpage wait for the server at that time would make the webpage appear sluggish.

Changing excel's upper context menu (the one with format options)

I'm trying to change context menu items using VBA, similar to this Microsoft's docs for my application yet, that one!
The end user will be attending to a line of customers and adding products to their, let's say, virtual "shopping cart".
This "shop" has very limited items on sale and they would fit easily on the context menu and by clicking on then the user would add each item in a very 'well behaved' manner. Yet, I'm trying to make things a little faster, editing not only the main context menu (as explained on posted MS docs), but editing the upper as well.
It's a little improvement on the user side, as items will be closer to the cursor.
So, this question refers to "how-to", but any help, even the name of this menu, would be appreciated.
It's easier to find documentation when you know the names of stuff.

How can I activate (display) a view using Revit API?

I am trying to activate a view using Revit API. What I want to do exactly is to prompt the user to select some walls, but when the user is asked that, he can't switch views to select more walls (everything is greyed out at that point).
So the view I want to activate (by that I mean, I want this view to be actually shown on screen) already exist, and I can access its Id.
I have seen threads about creating, browsing, filtering views, but nothing on activating it... It's a Floor Plan view.
So far I can access its associated ViewPlan object, and associated parameters (name, Id, ..).
Is it possible to do ?
Thanks a lot !
Arnaud.
I think the most preferred way is the UIDocument.RequestViewChange() method. The tricky part about this is that unless you've designed your application to be modeless with external events or idling, it may not actually happen until later when control returns back to Revit from your addin.
(There's also setting the UIDocument.ActiveView property - not positive if this has different constraints).
The other way that I have done it historically is through the use of the UIDocument.ShowElements() command. The trick here is that you don't have control of the exact view - but if you can figure out the elements that appear only in that view, you can generally make it happen (even if you have to do a separate query to get a bunch of elements that are only in the given floorplan view).
Good Luck!
I think the solution to your problem may be:
commandData.Application.ActiveUIDocument.ActiveView = View;
The ActiveView is a property and it has {get and set} options.
ActiveView has only a get accessor, what Mostafa suggests will not work.
I have used the RequestViewChange() method with a modal dialog and have not had problems so far.

Core Data Multiple FetchedResultsController/Views: How do you update all manually?

I have two instances of the same ViewController class accessed in different tab items. Both use the same entity, but with a different predicate. One displays all the items, while the other displays a subset based on its predicate.
The problem occurs when I delete an object from the "All" list. It updates immediately, but when I switch over to the other tab, the object is still there, even after going back and forth in the views. Only after a period of time, around 5 to 10 seconds, does the deletion get reflected in the other view.
The ViewController class use a FetchedResultsController.
Any ideas what the cause is and how to get the results to immediate appear?
Just put a reloadData into viewWillAppear. You can also catch this when the tab bar's selected index changes.
Apparently, there is no solution. There is no way to update UIManagedDocument manually.
This guy came to the same conclusion:
Core Data managed object does not see related objects until restart Simulator
So the solution is to use the default master-detail template and to stop using UIManagedDocument. Wish there was some documentation on this, would have saved me a day of my life.

How can I tell what change initiated a workflow?

If I configure a workflow to start when an item is changed, how can I tell which field changed to initiate the workflow? What I have in mind is I really only want the workflow to fire if one particular field changes and fall through any other time.
In simple terms, you can't.
Workflows don't hold "pre-change" and "post-change" properties like some events do.
The only thing you can do in a workflow is to check if a field value is "==" or "!=" to a value.
Some possible workarounds:
What you can do is write a event reciever to catch the list item updating event and then act on the data. James Love explained this in a great answer to "How can I detect whether a specific column changed in an SPItemEventReceiver.ItemUpdated event (SP 2010)?".
You can add a "hidden" field to the list that gets updated by the workflow when the list changes. This would hold the "old" value. Not practical, but simpler to implement than an event receiver.
Your title is a bit different than your question so i'll answer what I think is your question with a tutorial article.
http://sharepointsolutions.blogspot.com/2007/10/sharepoint-designer-workflows-how-to.html

Resources