Split Pipes

This is a method that can be useful for so many things that are not yet in the API, so I made a generalised version. It takes the “ID_xxx” name of any UI function as input and posts it.
I tried to put a switch in there to delay running until objects are selected in Revit (Eg with this) but I dont think it is working quite as it should.

import clr
clr.AddReference('RevitAPI')
clr.AddReference('RevitAPIUI')
import Autodesk
from Autodesk.Revit.UI import RevitCommandId
from Autodesk.Revit.UI import UIApplication
from Autodesk.Revit.UI import ExternalCommandData
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

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


#The inputs to this node will be stored as a list in the IN variable.
ID_Name = IN[0]  #Allows this to be used with any revit 'ID_xxx' input string
RunIt = IN[1] #Delay execution until selection set etc. has been made

if RunIt ==  True:
CmndID = RevitCommandId.LookupCommandId(ID_Name)
CmId = CmndID.Id
uiapp.PostCommand(CmndID)
errorReport = 'Success'
else:
errorReport = 'Set IN[1] to true to run'

#Assign your output to the OUT variable
OUT = errorReport

If you get the error “NoneType object has no Id” then the ID_xxx input does not exist.

1 Like