Dynamo | Toggle and Unify Revit Level Heads on Elevation Views​

I have recently stepped into Revit API to further extend Dynamo’s capability for optimising Revit sheet production. One simple task I started with was to be able to batch toggle Heads of Level Lines on Elevation/Section Views. I found the manual method very tedious with repetitive steps of firstly activating every single viewport of Level Lines to be adjusted, trying my best to precisely pick the actual Level Line, then carefully tick the box of Level Line Head Toggle on the side where I would like to show/hide it. Often I need to wait for 10s to see the changes taking effect especially on large project.

My aim was to batch toggle the Level Line Heads, to quickly show all Level Line Heads on the left or right, alternatively, to show/hide them on both ends of the Level Lines, and very importantly on selected views. This can be very helpful for sheet layout where I might want all Level Line Heads on the left visible for viewports on the left, etc.

The operation was enabled via Dynamo utilising Revit API, following a series of logics:

  1. Collect all Eligible views across the whole project. By saying Eligible, obviously plan views are excluded because they do not host Datum/Level Lines. Also roughly elevation/section views with no visible Datum Lines are also excluded, etc.
  2. Filter out the views based on selection or alternatively by sheet number, by-selection certainly provides better controls over the look of the final layout result.
  3. Providing 4 options of Level/Datum Line Heads Visibility, Left, Right, Both and None.

Problem and Solution, Unify Level Line Direction Before the Batch Bubble Heads Toggling:

One obvious issue I’ve identified immediately after the first attempt was the ‘random’ distribution of Level Line Heads turned on, meaning that some Heads will show at the left end while some are at the right end, even when explicitly telling Dynamo to only show Bubble Heads on left. After digging into the problem, I realise this is caused by the Non-Unified Level Line Direction.

When creating a new level in Revit, I tend to draw them from different direcitons from time to time, i.e. sometimes from left to right, sometimes from right to left. This is especially problematic when trying to set default Level Line Start and End bubble visibility or performing the latter attempted batch toggling operation. So I came up with a fix on this.

In Revit, Level Lines are represented by underlying lines, which do have end points and direction vector. Such Line element represent both the location of the level line in the 2D canvas of a viewport and the 3D extend of the datum plane. The changes made to unify the Start and End directions of all Level Lines should be performed based on the 2D setting, which is view-specific change. This is a safe modification as none of the elements locked to the 3D datum plane is affected.

Code Block 1 – Python Script in Dynamo Node: Unify Level Line Start and End Directions

Code Block 2 – Python Script in Dynamo Node: Mass Toggling Level Line Heads Visibility

Leave a Reply