Something that has been an ongoing pain in Revit for us all is the inability to location viewport titles through the API.

Thankfully in Revit 2022 they finally added this ability! I previously discussed this here.

The bummer is, this doesn’t change anything for us in older Revit versions. But…. using some weird workarounds, similar to the model group origin one I discussed here, Model Group Origin Hack.

Working in the Revit UI manually we can map this thought process out:

  1. On a sheet, recognize a viewport that has a mismatched view title.
  2. Re-Add the view to the sheet
  3. Notice the view title encompasses the entire viewport and is located fairly nicely.
  4. Admire the action you made Revit do that cannot be done.

Here is a GIF of this in action in the Revit UI: AlignViewportTitleRevitUI

However, there are some considerations:

  1. You cannot control view title length (easily) - There are ways to work around this if you modify the viewport crop and things like that, but it requires more thought.
  2. The view title placement is fairly uncontrollable outside of modifying the viewports crop region.
  3. The original viewport ID is deleted from Revit because you replaced it with a new instance.

With that covered we can automate these actions in a single Dynamo node. (with proper sequencing)

Here is a GIF of this new node in action: AlignViewportTitleDynamoNode

Full Overview Video

So…. exactly how does this look in code?

Unfortunately, it is top secret…. Just Kidding.

The whole source code is available below!

and here (for updates): https://github.com/johnpierson/RhythmForDynamo/blob/21da18426c3cba7c1abaee0e4cdb098a577c0ab7/src/Rhythm/Revit/Elements/Viewport.cs#L35-L73

It is worth noting that you would also probably want to store the viewport type, viewport number, and other parameters of interest before “re-placing” the viewport. But that is for another day.

Have Fun!

-JohnP

Other Links:

  • Someone else who thought similar (from 2017): Autodesk Forum

  • This was discussed briefly on this livestream here: LiveStream but I wanted to break it down more.