Getting Routing Preference Fittings Information

Hi, can we get access to Routing Preference family Types for Junctions, Unions etc for MEP Duct/Pipe types?

Hello
you can use the API
https://www.revitapidocs.com/2020.1/9fd171c5-b908-07d0-6fdc-bbcdcfae35a4.htm
an example

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

#import Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument

element = UnwrapElement(IN[0])
out = []

elemType = doc.GetElement(element.GetTypeId())

dictPrefEnum = dict(zip(System.Enum.GetNames(RoutingPreferenceRuleGroupType), System.Enum.GetValues(RoutingPreferenceRuleGroupType)))

routManager = elemType.RoutingPreferenceManager 
for name, enumVal in dictPrefEnum.items():
	ruleCount = routManager.GetNumberOfRules(enumVal)
	temp = []
	for i in range(ruleCount):
		routeRule = routManager.GetRule(enumVal, i )
		mepId = doc.GetElement(routeRule.MEPPartId)
		temp.append(mepId)
	if temp:	
		out.append([name, temp]) 	
OUT =  out
2 Likes

Hi, Thank you for your reply. It looks like working for Elements. I’m trying to make it work for list input and added “final_out” variable. Will you please help what am I doing wrong? I’m just starting to learn Python.

Hello @Sujan
try this
image

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

#import Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument


dictPrefEnum = dict(zip(System.Enum.GetNames(RoutingPreferenceRuleGroupType), System.Enum.GetValues(RoutingPreferenceRuleGroupType)))

toList = lambda x : x if hasattr(x, '__iter__') else [x]
elements = toList(UnwrapElement(IN[0]))

result = []
for element in elements:
	lstPreference = []
	elemType = doc.GetElement(element.GetTypeId())
	
	routManager = elemType.RoutingPreferenceManager 
	for name, enumVal in dictPrefEnum.items():
		ruleCount = routManager.GetNumberOfRules(enumVal)
		temp = []
		for i in range(ruleCount):
			routeRule = routManager.GetRule(enumVal, i )
			mepId = doc.GetElement(routeRule.MEPPartId)
			temp.append(mepId)
		if temp:	
			lstPreference.append([name, temp]) 	
	result.append(lstPreference)		
OUT =  result
3 Likes