Removing linked/imported CAD-Files
Hello,
I have a problem with my code(python) that needs to filter and delete all linked or imported CAD-Files in my project.
This is how I started, the deletion of the linked Revit & IFC-files is working smoothly. Only the CAD are causing trouble and dont seem to work the same way.
This is how this part of my code looks like right now:
# Helper function to delete all linked file types (Revit, IFC, CAD)
def delete_all_linked_file_types(doc):
# Collect all link types first
revit_link_types = FilteredElementCollector(doc).OfClass(RevitLinkType).ToElements()
ifc_link_types = FilteredElementCollector(doc).OfClass(ImportInstance).ToElements()
cad_link_types = FilteredElementCollector(doc).OfClass(CADLinkType).WhereElementIsElementType().ToElements()
# Delete Revit link types
for link_type in revit_link_types:
doc.Delete(link_type.Id)
# Delete IFC link types
for link_type in ifc_link_types:
if link_type.Name and 'IFC' in link_type.Name:
doc.Delete(link_type.Id)
# Delete CAD link types
for cad_link_type in cad_link_types:
doc.Delete(cad_link_type.Id)