hi @paris
as for the null values - I am sorry but there was a mistake in the output part of the script.
This is the corrected version, that should not produce null values (unless there is a reason for that)
However I think the unassigned system problem is still there - judging by the pipe colours.
As I probably said before, I have never used much MEP part of Revit and do not have much knowledge on it specifics. I do not have any ideas now about those unconnected caps and tees (don’t really know how they work in Revit). Sorry about that, If anything comes to my mind I will let you know. Although I am afraid that it might be a problem with BreakCurve method maybe and should be fixed separately ?
import clr
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
doc = DocumentManager.Instance.CurrentDBDocument
elements = UnwrapElement(IN[0])
points = UnwrapElement(IN[1])
output = []
children = {}
TransactionManager.Instance.EnsureInTransaction(doc)
for e, p in zip(elements,points):
to_check = [e]
if e.Id in children:
to_check.extend(children[e.Id])
splitId = None
for ec in to_check:
if isinstance(ec,Autodesk.Revit.DB.Plumbing.Pipe):
try:
splitId = Autodesk.Revit.DB.Plumbing.PlumbingUtils.BreakCurve(doc, ec.Id, p.ToXyz())
break
except:
pass
elif isinstance(ec,Autodesk.Revit.DB.Mechanical.Duct):
try:
splitId = Autodesk.Revit.DB.Mechanical.MechanicalUtils.BreakCurve(doc, ec.Id, p.ToXyz())
break
except:
pass
if splitId:
split = doc.GetElement(splitId)
if e.Id in children:
children[e.Id].append(split)
else:
children[e.Id] = [split]
output.append([ec,split])
else:
output.append(None)
TransactionManager.Instance.TransactionTaskDone()
OUT = output