As much as I enjoy using Revit, sometimes it can be a real chore. Let’s face it, there are certain things we need to do on a daily basis that are super tedious. Creating sheets, changing parameters, loading linked files – all these tasks eat up a lot of time, and as we all know, time is a precious resource. Those minutes or hours spent clicking the mouse could be better utilized on higher leverage activities like improving the design or getting home for dinner.
Plus, the computer is much better at doing these tasks than we are. It’s faster and more accurate. I start to zone out after only five minutes of doing the same thing over and over. This leads to errors and time wasted redoing work. Ugh. . .
Fortunately, through the magic of automation, we can harness the power of the computer to do this tedious work for us.
Revit Automation
Revit has been around for more than fifteen years. It’s a mature product. As I’m sure you’ve noticed, the rate of new feature development has slowed considerably. If you want Revit to do something specific, to make it work the way you work, you’re most likely going to need to do it yourself.
Learning to automate Revit is a bit like working on your car or fixing up your house. You’re going to look under the hood, get your hands dirty, and learn how things work. You already know how to use the software. Now it’s time to take things to the next level and really get productive.
Fortunately, it’s not too hard to get started. There are three options for automating Revit. You can visually program Revit using Dynamo. You can write custom add-ins with Visual Studio. Or, my favorite, you can write macros using Revit’s built-in macro editor.
Here’s a description of each method with some pros, cons, and additional resources to get you going.
Dynamo
Dynamo is a visual programming environment for Revit. It’s open-source software which you can download for free. Of all three methods, Dynamo is the new kid on the block and has generated considerable interest and attention.
In Dynamo, you create programs, or “graphs”, by connecting code blocks called “nodes”. Each node performs a specific function and has inputs and output. The process is very visual. Nodes are connected with lines that determine the sequence of events. One of the benefits to Dynamo is that you don’t need to know how to program, since the nodes contain all of the programming logic.
On the downside, Dynamo graphs can get really complicated. The more nodes you use, the more connecting lines you have in the graph. After a while, it looks like a lot of spaghetti on the screen. Also, you can’t create an interface for a Dynamo graph, so anyone else who wants to use your graph needs to have Dynamo installed and a working knowledge of the software. Another downside is that Dynamo graphs aren’t compiled so they tend to run slower than the other methods. Lastly, Dynamo is still evolving so it’s not fully mature. . . yet. There are things you can do with add-ins or macros that you can’t do in Dynamo without a little programming know-how.
That said, Dynamo is an exciting option for automating Revit. New nodes are being created daily and there’s an active community around the platform. Want to try Dynamo? Check out the Dynamo Primer or watch this video tutorial I put together on linking Excel to Revit using Dynamo.
Add-ins
Add-ins are the most powerful method for automating Revit but they’re also the most difficult for beginners. Add-ins are installed on the local computer and are accessible from the Revit Add-ins ribbon or a custom Ribbon. Add-ins are written in code (either C# or VB.Net) using an external programming environment like Microsoft Visual Studio. Once you write the add-in, you compile the code as a .dll file and load it into Revit using a XML manifest file.
Since add-ins are installed like software, they’re easier to distribute in an office environment. You just need to install the .dll and the XML file in the proper location and every user of that computer can access the add-in. In addition, you can fully customize the way the add-in appears on the ribbon. Jeremy Tammik’s blog, The Building Coder, is a great resource if you’re interested in writing add-ins.
One of the difficulties with creating add-ins is the learning curve. You need to learn the Revit API. You need to learn how to use Visual Studio. You need to learn how to connect Visual Studio to Revit. Additionally, you need to learn how to create controls in the Revit interface. It takes some time to get comfortable with each of these. That said, add-ins give you the greatest control over Revit and provide the most seamless interface with the software. Plus, if you create really useful add-ins, you can sell them on the Autodesk App Store.
Macros
Macros are my favorite way to automate Revit. They don’t require any additional software to create (like add-ins) but they still give you full access to the Revit API. Macros are written in code using SharpDevelop, Revit’s built-in programming environment. The macro code is saved within an RVT file, not in external files like add-ins. To run the macro, you must first load the RVT file. Macros are compiled so they run fast. You can also create dialog boxes for your macros, so they’re easy for non-programmers to use.
Here are three more reasons why I like macros:
- It’s easy to get started. You don’t need to install any additional software like you do for Dynamo or add-ins.
- You can convert macros into add-ins. Since the code is the same, it’s easier and faster to create the macro first then convert it to an add-in.
- Once you know how to write macros, you can leverage your knowledge of the Revit API to create custom nodes in Dynamo.
Want to start writing your own macros? Here’s the first lesson from my Mastering Revit Macro course. It reviews the basics of creating Revit macros and takes you step-by-step through the process of creating some simple macros. Give it a try!
One downside with macros is that they’re not as easy to distribute as add-ins. If someone wants to use a macro, they have to open the RVT file first. Once the file is open, you can run all the macros embedded in the file. This makes sharing macros more difficult in an office environment. Fortunately, it’s very easy to convert macros to add-ins.
Conclusion
Learning one of these Revit automation methods will drastically improve your efficiency. A well-written graph, macro or add-in can complete a tedious task with the click of a button, and save you hours in the process. As your skills grow, so will your ability to do the seemingly impossible. Automation takes time and patience but it’s a rewarding endeavor. Don’t be intimidated. Start small, be systematic, and develop your skills. Soon you’ll be on your way to automation mastery!
Want to learn how to automate Revit?
Check out my Mastering Revit Macros course. It will take you from complete beginner to Revit programming master in 8 real-world lessons.
Nice write up! I personally prefer dynamo for on the fly testing of a certain process and when i see that i use it a lot i will convert it to revit addin. I usually dont do macros for the simple reason that its hard to share them other than between your project team (people in the same revit file).
Thanks Konrad! You have a great site, by the way. I’m curious, what’s your workflow for moving from Dynamo to add-in? Do you use Dynamo to work out the logic then do all the coding in Visual Studio?
Intriguing, I look forward to your next installment. I haven’t seen much of Revit Macros before, and never used the AutoCAD macros since it was so much easier to write lisp that worked consistently, but it’s a pity Autodesk hasn’t put a macro recorder into Revit.
BTW: you referred to the bottom left hand of the screen but it is not visible in the video.
Thanks Krystof. Yes, it is a pity Autodesk hasn’t developed a macro recorder. That’s one feature of MS Office that I really like. I’ll often record a macro in Excel then go edit the VBA code so it’s more universal. It’s a great way to learn a software’s API.
Very nice write up Michael. Absolutely enjoy the things you share with the community. I am curious where I can go to sign up for your Mastering Revit Macros course? (I haven’t really searched the site for it, and probably should :o))
Thanks Brian. I’m putting the finishing touches on the course as we speak. It opens for enrollment this Thursday (Oct. 15th). I’ll be sending out an email or check the ArchSmarter homepage.
Thank you Michael!
My company uses application based macros. I have setup as part of a login script mirroring of the application macros from a centralized location to each user’s computer. Whenever I make changes to the macro I copy that macros folder from my computer to the central folder. The users then recieve the update at login.
That’s really interesting. So you’re copying the source .vb or .cs files from the master RVT file to the user’s computers. Is that correct?
No I build the macros as application based so it creates a folder for each module in programdata folder on the c drive with all the vb/cs related files within it. I copy the completed macro folders onto my server and mirror that directly to the users. Project based macros are painful to constantly update in all models and if you upgrade models and they no longer work you could have infinite models to fix
very interesting, I’ll wait for the mail…thanks
You can also automate Revit with a python console.
http://thebuildingcoder.typepad.com/blog/2013/11/intimate-revit-database-exploration-with-the-python-shell.html