public void DelElementByIds(List<ElementId> delIds)
{
Selection selection = _uiApp.ActiveUIDocument.Selection;
selection.SetElementIds(delIds);//选中要删除Element
RevitCommandId commandId = RevitCommandId.LookupPostableCommandId(PostableCommand.Delete);
_uiApp.ActiveUIDocument.Application.PostCommand(commandId);//使用PostableCommand进行删除
}
之前我是循环一个一个删,效率太低了,用PostableCommand就非常快。