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:
- On a sheet, recognize a viewport that has a mismatched view title.
- Re-Add the view to the sheet
- Notice the view title encompasses the entire viewport and is located fairly nicely.
- Admire the action you made Revit do that cannot be done.
Here is a GIF of this in action in the Revit UI:
However, there are some considerations:
- 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.
- The view title placement is fairly uncontrollable outside of modifying the viewports crop region.
- 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:
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.