Topo From Lines now in the free Revit tool set

This tool is an”oldie but goodie” that lets you create and update a toposurface from a set of model lines. A new version for 2022 was recently requested, so I added it to the Terrific Tool project and created a 2022 build. You can download the current installer here and if you like code, that is here

TopoFromLinesScreenShot

Revit 2022: What’s up with ForgeTypeId?

If you’ve taken a look at the new Revit API or tried to update your apps to the new version, you may have seen a lot of errors about units because of API code that Autodesk deprecated in the 2022 API.

The great Extensible Storage Extension is one example of code that needs to be updated for these changes. I’ve made these updates in the Pull Request on Github and you can take a look at the changes which might help you make the changes in your own code. There are also some examples here.

Also, you can’t use a “switch” statement to check ForgeTypeId values, so the code below needed to be changed to use if/else

Also, when you use the Extensible Storage Extension, there are fields that previously required a “UnitType” to be specified like this:

        [Field(UnitType = UnitType.UT_Length)]
        public double offset { get; set; }

A reasonable guess at how to update that code would be

       [Field(SpecTypeId = SpecTypeId.PipingVelocity.TypeId)]
public double Property3 { get; set; } 

But this will give you a compilation error “An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type”. TypeId does return a string, but because it is a property and not a “const string” it can’t be used this way. You can’t read SpecTypeId properties in an attribute initializer because they aren’t constant expressions.

To solve this, use the string literal value of the

[Field(SpecTypeId = “autodesk.spec.aec.piping:velocity-2.0.0”)]
Public double Property3 { get; set; }

And you can find the string literal value with a bit of code like: TaskDialog.Show(“test”, SpecTypeId.PipingVelocity.TypeId);

Level Displacer now available for free on all Revit versions

The Level Displacer tool has been available for several years on the App Store. This tool allows you to create an exploded view of your model by automating the process of creating displacement sets for all elements on each level of your model. Each displacement set is translated a user-specified incremented value in the X, Y, and Z directions.

Self-publishing these tools is the quickest and easiest way to get them to you, so you can now get this tool as part of the free Boost Your BIM toolset

If you enjoy using this and the other free tools and educational resources from Boost Your BIM, drop us a line and let us know how you’d like to make Revit better. You can support our work on Patreon too!

Custom Errors – Preventing Specific Changes to the Revit model

Let’s say there is a specific list of View Scales that you want allowed in your Revit projects. Or certain naming conventions that should be used. Or something else like that where you’d like to automate the process of checking a user’s change and determining if it should be allowed, prevented, or trigger a warning.

This can be done with two pieces of Revit API functionality – Updater & Custom Failures. You can find all the code here and an explanation in the video below.

If you think lessons like there are interesting and helpful, please support Boost Your BIM at Patreon, take one of our video courses on the Revit API, or contact us to discuss how we can work together to make Revit better.

            Utils.ViewScaleUpdater viewScaleUpdater = new Utils.ViewScaleUpdater(application.ActiveAddInId);
            UpdaterRegistry.RegisterUpdater(viewScaleUpdater, true);
            UpdaterRegistry.AddTrigger(
                viewScaleUpdater.GetUpdaterId(),
                new ElementClassFilter(typeof(View)),
                Element.GetChangeTypeParameter(new ElementId(BuiltInParameter.VIEW_SCALE)));

            Utils.illegalViewRangeFailureId = new FailureDefinitionId(Guid.NewGuid());
            FailureDefinition.CreateFailureDefinition(
                Utils.illegalViewRangeFailureId,
                FailureSeverity.Error,
                "This view scale is not allowed.");

A better Select By Type tool

There are a few things you can’t do with Revit’s “Select All Instances” tool

  • You can’t select all instance of one type and then all instances of another type and combine them into a single selection set
  • You can’t select lines
  • You can’t restrict the selection to all instances in the active view

To solve these limitations, try the new FREE Select By Type tool in the Boost Your BIM Terrific Tools.
If you enjoy using this and the other free tools and educational resources from Boost Your BIM, drop us a line and let us know how you’d like to make Revit better and support our work on Patreon.

Sometimes it’s not you

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)
		.OfClass(typeof(WallType))
		.Cast<WallType>()
		.FirstOrDefault(q => q.Kind == WallKind.Basic);
	
	using (Transaction t = new Transaction(doc, "test"))
	{
		t.Start();
		Wall wall = Wall.Create(doc, 
            Line.CreateBound(XYZ.Zero, XYZ.BasisX),
            new FilteredElementCollector(doc).OfClass(typeof(Level)).FirstOrDefault().Id,
            false);		
		wall.ChangeTypeId(wt.Id);
		t.Commit();
	}
}

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.

How & When Were Your Revit Objects Created?

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.

You can download this tool for free and if you like it, please help makes these free tools possible by supporting Boost Your BIM at Patreon or taking one of our video courses on the Revit API.

Find Elements in a workset (or pretty much anything else in your Revit model)

Over on the Revit Architecture Forum, Felipe asks how to find all the elements on a workset. One great way to do that is with the Boost Your BIM Parameter Search tool

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.

Revit 2021 Units Upgrade for Family Type files

Your Family Type files may not work in Revit 2021 because Autodesk renamed several unit types. If you’d like a free tool to update your type files – here it is.

After this tool changes your family type files, those files won’t work in older versions of Revit because of the unit type renaming.

Ideas Forum post

https://forums.autodesk.com/t5/revit-ideas/revit-2021-resolve-parameter-unit-naming-problem-when-loading/idc-p/9845788#M34273

The Building Coder post

https://thebuildingcoder.typepad.com/blog/2020/04/revit-2021-unit-types-family-type-catalogues.html

Help file

http://help.autodesk.com/view/RVT/2021/ENU/?guid=Revit_API_Revit_API_Developers_Guide_Introduction_Application_and_Document_Units_html

Move lines in section to change plan view range – another new free open-source tool

Extending the power of this tool to create detail lines in a section view to show the plan view range, this new tool allows you to move those lines and update the view range.

Download the source code or installer – https://bitbucket.org/BoostYourBIM/boostyourbimterrifictools/src/master/

Support Boost Your BIM so we can make more great free tools – https://patreon.com/boostyourbim

Learn the Revit API so you can make your own great tools – https://boostyourbim.wordpress.com/learn/

Create lines to show Plan View Range – a new free open-source tool

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!

Download the source code or installer – https://bitbucket.org/BoostYourBIM/boostyourbimterrifictools/src/master/

Support Boost Your BIM so we can make more great free tools – https://patreon.com/boostyourbim

Learn the Revit API so you can make your own great tools – https://boostyourbim.wordpress.com/learn/

Paint Stripper – a new free open-source tool

Inspired by this post on the Revit Ideas forum, here is a new tool that will remove all Paint from your Revit model for one or more materials. Much faster than doing it one at a time!

Download the source code or installer – https://bitbucket.org/BoostYourBIM/boostyourbimterrifictools/src/master/

Support Boost Your BIM so we can make more great free tools – https://patreon.com/boostyourbim

Learn the Revit API so you can make your own great tools – https://boostyourbim.wordpress.com/learn/

Dockable Dialog with External Event

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.

If you like these tools, please support Boost Your BIM so we can make even more of them – take one of our online courses in API programming or support Boost Your BIM at Patreon

Like with all the Boost Your BIM Terrific Tools, you can find the source code & installer at https://bitbucket.org/BoostYourBIM/boostyourbimterrifictools/src/master/

New Free Tool – Pin Comment

From a suggestion on the Autodesk Idea Board:

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.

Like with all the Boost Your BIM Terrific Tools, you can find the source code & installer at https://bitbucket.org/BoostYourBIM/boostyourbimterrifictools/src/master/

If you like these tools, please support Boost Your BIM so we can make even more of them – take one of our online courses in API programming or support Boost Your BIM at Patreon

New free tool – Family Rename

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

Free tools for Revit 2020/2021 at the ADSK App Store

The Boost Your BIM tools on the Autodesk App Store are now available for all Revit versions.

Most of them are free and all of them are pretty good.

https://apps.autodesk.com/en/Publisher/PublisherHomepage?ID=FF48LFL26PXP

New free tool and Open Source initiative – Do Not Print by Category/Subcategory

We are excited to announce a new open-source initiative to make even more great Revit tools available to you and everyone who wants to make Revit better!

The first tool in this project lets you specify categories and sub-categories that should not be printed.

Code: https://bitbucket.org/BoostYourBIM/boostyourbimterrifictools/src/master/BoostYourBIMTerrificTools/PrintSuppression/

Download the Installer here

Please support Boost Your BIM on Patreon

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.

2021 changes Units

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.

https://boostyourbim.wordpress.com/2016/06/21/total-length-of-multiple-lines/
undefined

public void lineLength()
{
    double length = 0;
    Document doc = this.ActiveUIDocument.Document;
    UIDocument uidoc = this.ActiveUIDocument;
    ICollection<ElementId> ids = uidoc.Selection.GetElementIds();
    foreach (ElementId id in ids)
    {
        Element e = doc.GetElement(id);
        Parameter lengthParam = e.get_Parameter(BuiltInParameter.CURVE_ELEM_LENGTH);
        if (lengthParam == null)
            continue;
        length += lengthParam.AsDouble();
    }
    string lengthWithUnits = UnitFormatUtils.Format(doc.GetUnits(), SpecTypeId.Length, length, false);
    TaskDialog.Show("Length", ids.Count + " elements = " + lengthWithUnits);
}

More info on the new Units API is at

Revit Developer Guide documentation
https://help.autodesk.com/view/RVT/2021/ENU/?guid=Revit_API_Revit_API_Developers_Guide_Introduction_Application_and_Document_Units_html

What’s New in 2021 API
https://thebuildingcoder.typepad.com/blog/2020/04/whats-new-in-the-revit-2021-api.html#4.1.3

The best way to upgrade your Revit files

The top-rated upgrade tool in the Autodesk App Store is back for Revit 2021.

Satisfied customers say:

“Our teams with large campus projects no longer groan when it is time for the annual upgrade.”

“There are other solutions floating around in cyberspace but this one is the Holy Grail.”

“I have been using the Bulk File Upgrader for years. The best and easiest add-in to use. I recommend this to anyone who needs to upgrade files.”

“This program is amazing. It works great in all ways that you would expect. “

Features include:

  • Select which file types to upgrade
  • Add suffix to new file names
  • Set “workset open” option (All, Editable, Last Viewed, Specify)
  • Speed the opening process by only opening specified worksets
  • Options to
    • Discard worksets
    • Delete backup folders
    • Relinquish editable worksets
    • Delete backup files
    • Remap RVT Links when saving to a new folder
    • Open files with Audit option

Your purchase helps support all the free API content and training material here at Boost Your BIM.

File Upgrade