LearnRevitAPI

Apr 25, 2024

How to use IUpdater?

It's time to cover IUpdater on the channel!

It's a very requested feature, and it offers a lot! We can literally create a lot of new functionality in Revit, as it allows us to add certain code to every change that happens in our projects. 

So, whenever you move an element, we can make additional changes, and it's huge!

💡Watch this video to learn more about it, or read it briefly here.

Dynamic Model Update

DMU (Dynamic Model Update) provides an ability to monitor for changes and inject additional changes when they happen. And to do that we need to use the IUpdater Interface

This is an incredibly powerful feature, because we can create a lot of new features in Revit that we thought were not possible before.

e.g.:

- Track Element Coordinates
- Write Timestamps and Names when elements were modified
- Report Mirror state of Doors

There is literally infinite possibilities what we can do with it.

And it's not a rocket science to do that, but you should certainly be very careful with what you do, as it might affect your team at scale.

pyRevit + IUpdater 

IUpdater involves a lot of steps to create it, but luckily pyRevit simplifies it for us.

However, I would still recommend you to go through Revit API Developer's Guide and read more about it here

But I will show you how to create it simple with pyRevit hooks.

Create IUpdater hook 

Creating hooks in pyRevit is very easy. We just need to create hooks folder in the root of our pyRevit extension where we have the .tab and lib folders.

-YourExtension.extension
    - hooks
    - .tab
    - lib    

Then we need to create a python file with the correct name. You can learn more about possible names here, but for IUpdater we need to create a script named doc-updater.py

doc-updater.py 

The syntax in this file will be a little different, because we are dealing with an event. Therefore, we have to work with EventSender and EvenetArguments.

Here is a base script you can use to get doc variable and lists of Modified/Deleted/New Element Ids.

Now we can dive deeper and add a few new features. I will iterate through all modified elements and check if they are in the list of allowed categories (Windows, Doors) and if they have a class of FamilyInstance.

You can introduce your own checks here, but this is what I will be working with in my tutorial.

Now let's go through these features that I want to add.

Feature #1 - Track Coordinates

First of all I want to report the origin coordinates in Meters. This is very simple; every time our WIndows or Doors are marked as modified, we will look at Location.Point coordinates, convert them to meters and write the results to one of the parameters.

Feature #2 - Write Timestamp + Name

Also I want to add a timestamp and the name of the user who made the change. This is fairly simple to do, and you can see the code here:

Feature #3 - IsMirrored

Lastly, We will check if Window/Door is mirrored or not, because it's important to know when you want to order them correctly.

And it couldn't be easier than that:

Final Code

We didn't need a lot of code to add 3 new features to Revit:

- Track Coordinates
- Add Timestamps and Usernames
- Report Mirror State

And here is the final code:

😉Make sure you watch the whole video to see it in action

Enjoyed Newsletter?

Leave a Testimonial Here.

⌨️ Happy Coding!
Erik Frits

Join Newsletter

📩 You will be added to Revit API Newsletter

Join Us!

which is already read by 6800+ people!

Last Chance To Claim LIFETIME ACCESS. (Only ~50 Seats Left)