LearnRevitAPI
![](https://framerusercontent.com/images/zMFB840Y52OLteloUT4BRuogE.png)
![](https://framerusercontent.com/images/U9zjOvD4k3m6cIJd5bOiu960DeI.png)
Sep 30, 2023
Select Elements Modifed By a User
![](https://framerusercontent.com/images/Sd5FTaxiqzG7oeH1ykV6yypUzXo.png?scale-down-to=512)
🤔 Have you ever wondered, "Who did this or changed that in our work-sharing Revit project?"
Well, pyRevit has a tool that can give us answers for one element. But what if we need to select everything that someone changed in our project?
💡 Let's learn how to select elements that were last modified by someone.
![](https://framerusercontent.com/images/Cq8T4tMidPmsEGZXGog6L9GLGZw.png)
👀 Get All Elements
➡️ First of all let's get all 3D Elements in our Revit Project, so we can sort it by users. Obviously we will use FilteredElementCollector.
I will also make sure that I am selecting Family Instances and they are View Independent .
![](https://framerusercontent.com/images/RPsrvMWpXgcvytTkhNx5tVsTM.png)
💡 You can use different method to get your elements.
👽 Who Did That?
🔁 To sort elements by user we need to get that information from Elements. There is a class in Revit API WorksharingUtils.
👉 Inside there is a method called GetWorksharingTooltipInfo.
![](https://framerusercontent.com/images/KmEBookgY9jtKt8fyjaHiPZBM.png)
This method will return you WorksharingTooltipInfo.
And it has the following properties:
💡 You can choose which property you are interested in.
👇 Here is an example
![](https://framerusercontent.com/images/x981WoI8P8WUsjjGCUXxLYC4Koc.png)
↪️ Sort Elements by User
💡 Now we know how to get elements and get information about users from them. Let's create a dictionary where we sort all elements by LastChangedBy users.
📦 To do that, we will use defaultdict.
✅ They allow us to specify default value for each of the items in a dict. And we want each user to start with an empty list, so we can append elements to it.
❌ Otherwise you would need to check if user already exists in a dict, and either create an empty list or append to existing. We don't want to do that.
![](https://framerusercontent.com/images/o9iCRMFMj7thy97gANyWpoGxjbo.png)
👉 Select User from List
✅ We have a list of all elements sorted by users. Let's ask our end-user whose elements we want to select.
📃 For that we will use SelectFromList form from pyrevit.forms. It's very simple to use and pyRevit documentation has examples that you can copy-paste.
![](https://framerusercontent.com/images/C4GQRLlnHPwCtU02xOrvmmYgtU.png)
![](https://framerusercontent.com/images/5u5SL0aDjrTZqof2MAhWll3Et3U.png)
💡 Check out pyRevit Forms if you never heard of them yet!
🎯 Select Elements
Now we have everything we needed. We just need to select these elements.
![](https://framerusercontent.com/images/MTghkmQKMKUXzbEryvIPi87rOQ.png)
Let's use Selection.SetElementIds()
It takes 1 argument which has to be ICollection<ElementId>
But we will use List[ElementId]
Here is the snippet that will prepare List[ElementId]
and change Revit UI Selection.
👇
![](https://framerusercontent.com/images/u9T3T10WkTcZyfWsA0gpvJiMBe0.png)
🎯 Final Code
✨ Here is the final Result put together.
![](https://framerusercontent.com/images/uQBjvW1JQuFos4IGgLHwr2UBHJQ.png)
P.S.
Hey guys, I am sorry for being so inconsistent on my YouTube and Newsletter...
As you already know I am very close to launch my Learn Revit API Course, but there is still so much work before I can release Early-Bird access.
I am already in the finish line, so I will do everything to release it this October. You will hear about it via my Newsletter for sure!
Join Newsletter
📩 You will be added to Revit API Newsletter
Join Us!
which is already read by 6700+ people!
![](https://framerusercontent.com/images/svHzzMLtnnRCxtCUwbgAm6CUeB8.jpg)
![](https://framerusercontent.com/images/Y44kwhY0i7q37LzXUjrlxeGUo.jpg)
![](https://framerusercontent.com/images/lqKYmh8rqwZwgY2C9MSQER6iBCI.jpg)
![](https://framerusercontent.com/images/SyGCvJ3dbHsJEyklWWBhweY.jpg)
![](https://framerusercontent.com/images/DwiaUdmQHs3FVdDH2PXwAr0Y.jpg)