Skip to content

Instantly share code, notes, and snippets.

@albisserAdrian
Last active August 28, 2019 06:50
Show Gist options
  • Save albisserAdrian/c463e4a8234a4d722808043e25b41baf to your computer and use it in GitHub Desktop.
Save albisserAdrian/c463e4a8234a4d722808043e25b41baf to your computer and use it in GitHub Desktop.
Revit API Delete Detail Elements
public void DeleteDetailElements()
{
Document doc = this.Application.ActiveUIDocument.Document;
FilteredElementCollector detailLines = new FilteredElementCollector(doc).WhereElementIsNotElementType().OfCategory(BuiltInCategory.OST_Lines);
IList<ElementId> detailLineIds = new List<ElementId>();
foreach(CurveElement dl in detailLines)
{
detailLineIds.Add(dl.Id);
}
FilteredElementCollector filledRegions = new FilteredElementCollector(doc).OfClass(typeof(FilledRegion));
IList<ElementId> filledRegionIds = new List<ElementId>();
foreach(FilledRegion fr in filledRegions)
{
detailRegionIds.Add(fr.Id);
}
using(Transaction t = new Transaction(doc,"Delete Detail Elements"))
{
t.Start();
doc.Delete(detailLineIds);
doc.Delete(filledRegionIds);
t.Commit();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment