How to change the Elbow,Crosses,Unions,ect in MEPCurveType's RoutingPreference using Dynamo?

I lookuped the API,I just can add a new RoutingPreferenceRule with the following code:

import clr

import System

clr.AddReference(‘RevitAPI’)
from Autodesk.Revit.DB import *

clr.AddReference(‘RevitNodes’)
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

clr.AddReference(‘RevitServices’)
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

MepCur_Type = UnwrapElement(IN[0])
elbow = UnwrapElement(IN[1])

TransactionManager.Instance.EnsureInTransaction(doc)
OUT = MepCur_Type.RoutingPreferenceManager.AddRule(RoutingPreferenceRuleGroupType.Elbows,RoutingPreferenceRule(elbow.Id,“弯头”))
TransactionManager.Instance.TransactionTaskDone()

but I want to change the existed one .Anyone can help me ?Thanks a lot !
I failed in this way too.

I convert the thought to access it:Add a new RoutingPreferenceRule first then remove the previous one.Setting the size to “ALL” successfully at the same time .


import clr

clr.AddReference(‘RevitAPI’)
from Autodesk.Revit.DB import *

clr.AddReference(‘RevitNodes’)
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

clr.AddReference(‘RevitServices’)
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

MepCur_Type = UnwrapElement(IN[0])
elbow = UnwrapElement(IN[1])

TransactionManager.Instance.EnsureInTransaction(doc)
new_PSC = PrimarySizeCriterion.All()
new_RPR = RoutingPreferenceRule(elbow.Id,“弯头”)
new_RPR.AddCriterion(new_PSC)
Routing = MepCur_Type.RoutingPreferenceManager
Routing.AddRule(RoutingPreferenceRuleGroupType.Elbows,new_RPR)
Routing.RemoveRule(RoutingPreferenceRuleGroupType.Elbows,0)
TransactionManager.Instance.TransactionTaskDone()
OUT = 0

1 Like