[Revit] Add sizes to a pipe segment using python + Dynamo + Excel

I didn’t want to use Dynamo as I really prefer line code programming to visual programming. But in fact Dynamo :

  • has a very active community
  • is open source too
  • use python as main scripting language
  • is great for debugging python script as you don’t need to include every single line in a try/except block
  • is much user friendly than as it is now included with Revit 2017.1 and by the way this new Dynamo Player makes it usable by anyone
  • scare many people less than line code so they can easily modify to adapt it to their objectives

Here is the Dynamo image. It uses Clockwork package :


File is available here

Here is the python code block :

import clr
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Plumbing import PipeSegment

from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

#Les entrées effectuées dans ce noeud sont stockées sous forme de liste dans les variables IN.
dataEnteringNode = IN

elem = doc.GetElement(IN[0])


for dn, di, de in zip(IN[1], IN[2], IN[3]):
	DN = UnitUtils.ConvertToInternalUnits(dn , DisplayUnitType.DUT_MILLIMETERS)
	Di = UnitUtils.ConvertToInternalUnits(di , DisplayUnitType.DUT_MILLIMETERS)
	De = UnitUtils.ConvertToInternalUnits(de , DisplayUnitType.DUT_MILLIMETERS)
#Affectez la sortie à la variable OUT.



  1. Hi,
    I’m very interested in getting the code and the Dynamo file for this, but the link is not working
    (broken) Would you be able to update or email me the code.



      1. Thank for fixing the link!
        We have another question related to Revit/Dynamo/Excel.
        We would like to extract the “Nominal”, “OD” and “ID” data from the pipe system family and insert it into an excel spreadsheet to use in the loadable families. Right now Revit only shares the “Nominal” information with the loadable families, which creates havoc when we have different pipe sizes than what the nominal size is called out as, for instance – 24″ ID pipe has a 26″ OD, but the nominal is 24″ We have been searching and have not found a workable solution other than create “hundreds” of loadable families, which we are not interested in doing.

        1. Hi Charles,
          Why don’t you use lookup tables ? Even in real life ID and OD are not always exactly the same between pipes and fittings (eg. for welded steel pipes). I personnally use lookup tables and formulas to apply the correct ID/OD to fittings and accessories.
          You anyway need to adapt radius lenght etc… with a lookup table. I have for exemple one elbow per material (welded steel, welded stainless steel, PE, PEX etc…).

  2. Hi, I want to ask you a question. I wrote a dynamo, for automatic sprinklers, using excel, but did not work. Can you help me ?

  3. Thanks for your dynamo, but I faced an issue after running code i got an error of ” Expected Reference, got list” Please advise??

    1. This article is pretty old. Some nodes way to work may have changed. Instabilities in nodes/extensions is the main reason why I don’t use Dynamo a lot. Nevertheless it is now really more stable than in 2016.
      A reference is a single object, a list is a list of undefined object. The node where the error occur seems to accept only 1 object of type Reference and you provide it a list (use watch etc… to visualize what transit between nodes).

  4. Thank you for you script.
    i have this error: image on link https://ibb.co/WxJYD7S

    The warning I have is this one could you please help?

    Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
    Traceback (most recent call last):
    File “”, line 15, in
    TypeError: expected Reference, got Int64

    Thank you!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.