Centering Viewport Titles under Viewport

On most of my projects, I have to spend a lot of time trimming the viewport title’s line to match the length of the text and centering that title underneath the viewport. Does anybody know of a script that could do this for me on all views in the model? See below for example of what I want done.

which Revit version are you in? This was officially added to the API in Revit 2022

1 Like

I’m in Revit 2022. I’m new to Dynamo so I really have no idea what I’m doing, or where to start.

Ok, that makes sense. Well, welcome to the forum!

I really suggest working through the primer when you have a chance. But, let me break down the thought process around this idea. (Apologies if any of this is review, I just want to be thorough)

Also, it is worth noting, that this might be considered more of an advanced workflow because of some of the weirdness with how dynamo handles units. Some are paper space, some are model space, etc. It is actually quite frustrating to me even, and I have been fighting with Dynamo for a few years now. :unamused:

1. Initial Collecting of Revit Elements

With Dynamo you generally start with needing to select/collect what you are working with. In your case, that is viewports. So we have a few options here. (Note: all OOTB ¹ collection methods are under Revit>Selection)

In your case, you mentioned “All Views” so a categorical² selection is probably the correct way to go. (This might need to be more specific if you have odd views on the sheets).

2. Working with Certain Classes³ of Revit Elements

Since you mentioned viewports, all of the relevant nodes are going to be under Revit > Elements > Viewport. Luckily in 2022, OOTB nodes encompass what you would like to do.

3. The logic involved.

In this case, for viewport titles, the label outline will report the total size including the line. So I think in order to get the text, minimizing the line, measuring, then setting it to that value should do. (This is a bit more intermediate/advanced, but the logic is there.

as you can see, the bubble is accounted for as well. you could add additional math to fix this

4. Centering under the viewport

Taking this new view title line, we should be able to reconstruct a new location of this title.

The summary of what is happening below is,
a. we are obtaining the center of the viewport with the outline max and min points. this is for our x value
b. We are also getting the bottom left point for our y value
c. using those values we are constructing a centered location below the viewport.

5. Final Result + Finished Graph

SetViewportLabelToTextWidth.dyn (68.5 KB)


I made this post mostly to work out the logic required when getting going with Dynamo. I can’t gurantee that the attached graph will work for your exact use-case, but I do find this workflow intriguing and will probably add nodes to Rhythm for it and make a full tutorial video on it.

Terms Used in Post ¹Out of the box

² Categorical collections are typically “placed” elements

³ Classes of elements in Revit are their object types. Walls, Floors, etc.


Thank you so much for your in-depth response! I’m going to give this a shot once I get some other things done and I’ll let you know how it goes!

1 Like