hello all -
this should be a somewhat easy one. i'm trying to delete many elements by category using category filters and iterating through and deleting each element (to ensure i'm not trying to delete an element which has been deleted due to it's hosting element being deleted). everything is fine except for curtain wall systems, panels and mullions. should be straight forward but it's throwing errors, see code and image below.
code:
//***************************** List<ElementFilter> catFilterList = new List<ElementFilter>(); //............................................ //............................................ //............................................ catFilterList.Add(new ElementCategoryFilter(BuiltInCategory.OST_Curtain_Systems)); catFilterList.Add(new ElementCategoryFilter(BuiltInCategory.OST_CurtainWallPanels)); catFilterList.Add(new ElementCategoryFilter(BuiltInCategory.OST_CurtainWallMullions)); //............................................ //............................................ //............................................ FilteredElementCollector coll = new FilteredElementCollector(doc); LogicalOrFilter catFilter = new LogicalOrFilter(catFilterList); coll.WherePasses(catFilter); ICollection<ElementId> elemIdList = coll.ToElementIds(); foreach (ElementId id in elemIdList) { try { if (doc.get_Element(id) != null) { delCt += doc.Delete(id).Count; } } catch { } } //*****************************
error:
any help is much apreciated. thanks.
--Best
Curtain wall's panels cannot be deleted directly via Revit UI. If wall panels are selected, the delete command is gray in the UI.
If the curtain wall is deleted, then all the panels in this wall are deleted.
You can just exclude the category of the wall panel from the logical filter.