swapping titleblocks…the easy way

image by archi-lab

This particular workflow came up recently when one of the Design Technology Managers at HOK asked if it was possible to swap bunch of Titleblocks for a different one, while retaining all of the parameters in tact. As you are all aware, all of the view/sheet parameters transfer (or rather don’t change) when a Titleblock is changed on a Sheet, but the Titleblock parameters themselves get all reset to their default values. Especially if the parameters don’t match names and types across Titleblocks, it’s a major hustle. It’s rather rare, to have any Titleblock specific parameters, but some like Stamp, or KeyPlan visibility are usually assigned to Titleblock rather than a Sheet. I might have my opinion about that, but in general it is what it is, so let’s move on and see how this can be solved:

First we need to select all Titleblocks and Sheets. Wait…what?! Yes, Sheets and Titleblocks are separate entities in Revit. They are connected by means of Sheet Number. So basically a Sheet, and a Titleblock will share the same value for parameter Sheet Number, but they are two different objects. Now, to get started we need to get all Sheets and all Titleblocks and then arrange them into pairs or parallel lists with matching order. Normally we can select all Titleblocks like this:

However, in this particular workflow we need to use Python to do this. Why? Because certain nodes in Dynamo have Element Updated event programmed into them, which causes them to refresh when any of the elements that’s being passed through them changes. One of those nodes is All Elements of Category. Why do we care about this? Well, what we want to do is to get some parameters from our currently used Titleblocks, replace the Titleblock with new (this will trigger element updated event), and then assign previously retrieved values to new Titleblock. You see the problem now? It’s the sequence of actions that we need, that cannot be achieved if after our second step Dynamo refreshes all of our Tietleblocks, hence erasing all of our previously retrieved parameter values. One way to remedy that, is to use a Python script node. These nodes don’t refresh automatically, hence, we can keep the retrieved values longer, and even after we switch Titleblocks they won’t get erased. Let’s get right to it:

The code for selecting all of the Titleblocks and Sheets looks something like this:

Then we have the code for getting all of the Sheets:

As you have noticed there is one more Python node on canvas. We are using it to check if a Sheet is a Placeholder, so we can exclude them. Remember that Placeholder Sheets do not have Titleblock assigned, so we can safely exclude these from our workflow. Here’s that short code:

Once we have all that covered we can now match up our Titleblocks with Sheets.

You can see how we just retrieve the Sheet Number parameter from both Titleblocks and Sheets, then use List.IndexOf and List.GetItemAtIndex to retrieve a matching list of Titleblocks/Sheets. We can then move on to our next step, which is to retrieve some of the parameters, swap Titleblock and write these parameters to it.

That’s it! You have effectively replaced Titleblocks for Sheets, without losing any previously assigned parameters. I hope this was useful.


Support archi-lab on Patreon!


  1. Alexis Kotzambasis says:

    Always learn something new and interesting from your posts. Thanks Konrad

  2. Joris says:

    Hey Konrad,

    Starting to fiddle with your script, but failing atm.
    I want to adjust the script in a way that it doesn’t require a single title block type as new one.

    In my case the title blocks to be replaced are the same, with same types.
    So familyname 00_PA_TB – …. becomes 00_EEC_TB – ….
    All the types are the same for both families.

    Please see attached the adjusted verison. Any thoughts on where I’m going wrong?

    Attachment:  swap.zip

  3. Deyan says:

    Nice one man! The blog that keeps on giving!

    I hope your new adventure is giving you maximum returns in all sorts of ways! ^^

Leave a Comment