Pipe diameter list

Im making a script for dynamo player.
So i want a list which contains only pipe diameter like how we give inputs in revit.
pipe%20dia%20list%20revit

Currently im working like this:

Any suggestions in packages or logic. Thank you so much :slightly_smiling_face::slightly_smiling_face:

use this code to get all the pipe segment size available with the pipe type.

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

# Import python library
import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)
import os
import shutil

#Import Data and Time
from datetime import datetime
now = datetime.now()

# Import math library
from math import *

# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

# Import Element nodes in Dynamo
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)

# Import DSCore nodes in Dynamo
clr.AddReference('DSCoreNodes')
import DSCore
from DSCore import *

#Import System Library
import System
from System.Collections.Generic import *
from System.IO import Directory, Path

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application

segments = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_PipeSegments).ToElements()

norminal,name = [],[]

#Preparing input from dynamo to revit
for seg in segments:
	sizes = seg.GetSizes()
	name.append(seg.Name)
	temp = []
	for size in sizes:
		temp.append(size.NominalDiameter * 304.8)
	norminal.append(temp)
#Do some action in a Transaction
TransactionManager.Instance.EnsureInTransaction(doc)

TransactionManager.Instance.TransactionTaskDone()

#Final output
OUT = norminal,name

and as for the list drop down, i would suggest you to use data-shape packages. Unless there is an custom node that allows you generate custom dropdownlist, which then can be used as dynamo player’s input.

Hi, would it be possible to get the inside and outside diameters as well? Thanks!!

yes it is possible. you can see it listed on properties. Try to search from get parameter node.

Dear @stillgotme I would like to use your code for conduits and when I did look at your code I notice that I probably must change the category and method GetSizes. I did find that category should be BuiltInCategory.OST_Conduit but for a method that will collect all sizes I guess GetConduitSizeSettings but Dynamo gives me a warning that my method is not appropriate.

Can you tell me how I need to modify the code in order to retrieve conduit sizes? Thank you in advance.

if you see the api docs, you can see that the method is a static method, so you could just use ConduitSizeSettings .GetConduitSizeSettings(adoc), outside the forloop

@stillgotme Thank you for your quick response. I did play but unfortunately, I was not able to write that code. If you have time and if you think that is simple can you please write me down changes in your code that can retrieve conduit sizes? Again, thank you in advance.

@stillgotme
I did get size settings but from that point, I do not know how to retrieve all sizes. I would say that this is probably not a good class for this case.

The thing is that I would like to retrieve all sizes from the model even in situations when I do not have any conduit modeled currently in the model. So probably I should use ConduitSize class with NormalDiameter property but again I do not know how to link them together. :frowning:

Any help is highly appreciated.

@nenad.kovacevicUJ7NU that is definitely the correct class. you just need a little bit more investigation to it. When you see the class inheritance of the ConduitSizeSettings. You will know notice that it inherits an IEnumerable<KeyValuePair<string, ConduitSizes>>, as shown:


This means you can just use that conduitsizesettings class object and loop it through each for loop or while loop to get its name of the setting and as well as all the size within it. I would rather teach you the rational behind it rather than typing how to source code for you. So, good luck :slight_smile:

2 Likes