
TaskDialog.Show("Dialog", "There isn't any door in the project") IList listOfDoors = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Doors).WhereElementIsNotElementType().ToElements() If (doc = null) throw new InvalidOperationException("Could not open document.")

If (rvtApp = null) throw new InvalidDataException(nameof(rvtApp)) Public static void DeleteAllDoors(Application rvtApp, Document doc) Prompt += " more dependent elements have also been removed."

String prompt = "The selected element has been removed and " Throw new Exception("Deleting the selected element in Revit failed.") ICollection deletedIdSet = document.Delete(element.Id) Public static void DeleteElement(Document document, Element element) Public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) Public class DeleteDoorsApp : IExternalCommand

If you want more details on the meaning of each line, refer to my previous courses on the Revit API. I have retrieved it from the Revit API Documentation. When calling the DeleteAllDoors Function, in its turn, it calls the DeleteElement Function. Therefore, The Execute calls DeleteAllDoors that looks for all the doors that are in the project and delete each one. There are 3 parts of functions in the code : Execute, DeleteAllDoors and DeleteElement and each one calls the other. The objective in this lesson is to create an *External Command that will be able to delete all doors in the project and give a message if there is no door.
