Thanks @solamour for the additional feedback. After thinking more about this, it seemed better to wrap all of this up into one node. One key piece was calling the Transaction manually rather than the TransactionManager. No matter how I tried to slice it, it kept telling me I couldn’t edit because no transaction was open.
import System
import clr
clr.AddReference("RevitNodes")
import Revit
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
clr.AddReference("RevitAPI")
import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
paths = IN[0]
if not isinstance(paths, list): paths = [paths]
cats = IN[1]
if not isinstance(cats, list): cats = [cats]
status = []
errorReport = None
for path in paths:
try:
doc = app.OpenDocumentFile(path)
trans = Transaction(doc,'del')
for cat in cats:
collector = FilteredElementCollector(doc)
collector.OfCategory(System.Enum.ToObject(BuiltInCategory, cat.Id))
collector.OfClass(FamilySymbol)
types = collector.ToElements()
trans.Start()
for type in types:
doc.Delete(type.Id)
trans.Commit()
doc.Close(True)
status.append('Closed')
except:
import traceback
errorReport = traceback.format_exc()
if errorReport is None:
OUT = status
else:
OUT = errorReport
Thanks for the help on this one, I needed to learn more about how Dynamo handles items up and down stream of closures and deleted items.