Here’s a really simple bit of code to create a wall and change the wall type
public void crash()
Document doc = this.ActiveUIDocument.Document;
WallType wt = new FilteredElementCollector(doc)
.FirstOrDefault(q => q.Kind == WallKind.Basic);
using (Transaction t = new Transaction(doc, "test"))
Wall wall = Wall.Create(doc,
The problem is that when you create a wall with the Revit API, Revit uses the wall type last used when a wall was created with the user interface. If the last wall type used was a basic wall, then everything is fine. But if the last wall type used in the interface was a Curtain Wall…
You can work around this by adding a Document.Regenerate() just before changing the wall type. But it is a good reminder to think about how Revit’s state can affect your add-in, be careful working in the API with newly created elements, and that sometimes by adding a “regenerate” or changing how you are using transactions you can find a solution.
Oscar suggested that Revit could have an “action log” that, as an instructor, he could use to find out if students are cheating by “copying the assignment or parts of it from another student”. Here’s a look at how the Revit API solve this problem.
When every element is created, the time and tool used (for example the Wall command, Mirror, Rotate, or Paste…) are secretly and invisibly stored on the element. A user-visible command copies that data into a standard Revit parameter. So if Oscar has all his students run Revit with this tool installed, he can check their work by running the command and seeing how many elements were created with each command.
If this tool or the how-to posts on this site help you do more with Revit, please support Boost Your BIM at Patreon or take our video courses at Udemy so we can make more tools and share more knowledge about how you can make Revit better.
Back in 2016 I granted an API wish during Revit Technology Conference to create lines to visualize the planes of the Plan View Range. Now that tool has been added to the Boost Your BIM Terrific Tool set!
These are two key pieces of Revit API technology that work great together like peanut butter and chocolate
To be honest, RegisterDockablePane + XAML + IExternalEventHandler don’t taste as good as a Reese’s Peanut Butter Cup. But you can use them to create a simple little modeless dialog with a button that creates new drafting views. And from here this basic sample can be a launching pad to all sorts of great Revit tools.
When you pin something there should be an option to write something in a “comments” field. If someone unpins that thing then the comment you wrote would pop up like a warning dialogue. This way they would know why the thing was pinned in the first place.
I’ve created a new free tool that uses the DocumentChanged event and an External Event to prompt the user for a reason when an object is pinned. When the object is unpinned, it shows the username and reason.
Here’s another new tool in the open-source Boost Your BIM Terrific Tools. In the CSV file, enter the existing family names and the new names that you want the families to have. Run the tool and your families are renamed.
M_RPC Beetle,Beetle Car RPC Female,Woman RPC Male,Man Photovoltaic-Panel-SolarWorld-SunModule-(235-240),Solar Panel
Please help Boost Your BIM continue to provide so many free tools and free code samples that help you make Revit better. There’s a lot of great new stuff that Boost Your BIM has coming soon – please visit to https://www.patreon.com/BoostYourBIM to help make these resources possible.
Autodesk made a bunch of changes to the Revit API for Units in 2021. Many frequently-used methods are now marked as obsolete. They still work just fine in 2021 but Autodesk will probably remove them in 2022.
For one example of how to update your code, this old sample computes the total length of all selected objects and shows the result as a formatted string. The new code, which uses the method UnitFormatUtils.Format Method (Units, ForgeTypeId, Double, Boolean) is shown below.
Revit Lookup is a great open-source tool to help you better understand the data in your Revit model. I use it every day, and even if you aren’t writing Revit API code, sometimes it is still useful to get “under the hood” and better understand the data in your Revit model.
You can download the source and build it yourself, but that is not for everyone. So I created an MSI Installer that you can use to install the Lookup tool for Revit 2019, 2020, and 2021. I also submitted some changes to make it easier to build Revit Lookup for any release of Revit. Jeremy wrote a bit about it at The Building Coder.
I built the installer with Advanced Installer, a very powerful and easy to use tool for building your own installations developed by Caphyon. The drag-and-drop interface lets you quickly select the files you want to install and where the installation should place them on the target computer.
Advanced Installer has a freeware version with plenty of capabilities for many Revit API developers. If you want to support them and get even more features there are three different licenses that you can purchase.
Revit Lookup is a great (and free) tool to learn more about what’s in your Revit models. If you want to look at source code, deal with GitHub, and learn more about it, go to https://github.com/jeremytammik/RevitLookup
This post on the Revit Ideas forum inspired a new lecture on the Boost Your BIM Revit API course at Udemy. It is a great example of how just a few lines of code (17, to be exact) can be written in just a few minutes to do something useful.
When “tab” selecting a string of lines (egress lines for example) if you select all the lines in that string it should give a value for the overall length of that sting, instead of having to select each individual line and adding the lengths together yourself. this would help with more than egress plans too.