[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 :

ajoutertaillessegmentstuyaux

File is available here

Here is the python code block :

import clr
clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Plumbing import PipeSegment

clr.AddReference("RevitServices")
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])

TransactionManager.Instance.EnsureInTransaction(doc)

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)
	try:
		elem.AddSize(MEPSize(DN,Di,De,True,True))
	except:
		elem.RemoveSize(DN)
		elem.AddSize(MEPSize(DN,Di,De,True,True))
		
#Affectez la sortie à la variable OUT.
OUT = IN

Enjoy

5 comments

  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.

    Best,

    Charlie

      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…).

Leave a Reply

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