def deleteallinstances(family): matchlist = [] try: symbolidset = family.GetFamilySymbolIds() for symid in symbolidset: cl = FilteredElementCollector(doc).WherePasses(FamilyInstanceFilter(doc, symid)).ToElements() for faminstance in cl: matchlist.append(faminstance.Id) except: raise Exception for elid in matchlist: try: doc.Delete(elid) except: raise Exception
__window__.Close() from Autodesk.Revit.DB import FilteredElementCollector, FamilyInstanceFilter, ElementId from System.Collections.Generic import List uidoc = __revit__.ActiveUIDocument doc = __revit__.ActiveUIDocument.Document curview = uidoc.ActiveGraphicalView matchlist = [] for elId in uidoc.Selection.GetElementIds(): try: el = doc.GetElement(elId) family = el.Symbol.Family symbolIdSet = family.GetFamilySymbolIds() for symid in symbolIdSet: cl = FilteredElementCollector(doc).WherePasses( FamilyInstanceFilter(doc, symid)).ToElements() for el in cl: matchlist.append(el.Id) except: continue set = [] for elid in matchlist: set.append(elid) uidoc.Selection.SetElementIds(List[ElementId](set)) uidoc.RefreshActiveView()
if familyTypeName not in namesList: namesList.append(familyTypeName) countList.append(1) else: countList[namesList.index(familyTypeName)] += 1 for n, c in zip(namesList, countList): info += '{}: {} экземпляров\n'.format(n, c) arr.extend(els) counter = len(els) else: familySymbolIds = el.Symbol.Family.GetFamilySymbolIds() counter = 0 els = [] info = '' for i in list(familySymbolIds): col = FilteredElementCollector(doc).WherePasses(FamilyInstanceFilter(doc, i)).ToElementIds() for j in col: els.append(j) familyName = doc.GetElement(i).get_Parameter(BuiltInParameter.SYMBOL_NAME_PARAM).AsString() familyCount = len(col) counter += familyCount info += familyName + ((': ' + str(familyCount) + ' экземпляров\n') if familyCount > 0 else '\n') arr.extend(els) uidoc.Selection.SetElementIds(List[ElementId](arr)) string += info print('Выбрано ' + str(counter) + ' элементов') print(string)