コード例 #1
0
def deleteallinstances(family):
    matchlist = []
    try:
        symbolidset = family.GetFamilySymbolIds()
        for symid in symbolidset:
            for faminstance in DB.FilteredElementCollector(revit.doc)\
                                 .WherePasses(
                                     DB.FamilyInstanceFilter(revit.doc,
                                                             symid))\
                                 .ToElements():
                matchlist.append(faminstance.Id)
    except Exception:
        raise Exception

    for elid in matchlist:
        revit.doc.Delete(elid)
コード例 #2
0
def delete_all_instances(target_family):
    family_instances = []
    try:
        symbol_ids = target_family.GetFamilySymbolIds()
        for symbol_id in symbol_ids:
            for family_instance in DB.FilteredElementCollector(revit.doc)\
                                 .WherePasses(
                                         DB.FamilyInstanceFilter(
                                             revit.doc,
                                             symbol_id))\
                                 .ToElements():
                family_instances.append(family_instance.Id)
    except Exception:
        raise Exception

    for element_id in family_instances:
        revit.doc.Delete(element_id)
コード例 #3
0
selection = revit.get_selection()

for el in selection:
    try:
        # allow to select Type (FamilySymbol) from ProjectBrowser
        if isinstance(el, DB.FamilySymbol):
            symbol = el
        else:
            symbol = el.Symbol
        family = symbol.Family
        # do not collect element of the same family twice
        if family.Id in families_checked:
            continue
        families_checked.append(family.Id)
        symbolIdSet = family.GetFamilySymbolIds()
        for symid in symbolIdSet:
            cl = DB.FilteredElementCollector(revit.doc)\
                   .WherePasses(DB.FamilyInstanceFilter(revit.doc, symid))\
                   .ToElements()
            for el in cl:
                matchlist.append(el.Id)
    except Exception:
        continue

selSet = []
for elid in matchlist:
    selSet.append(elid)

selection.set_to(selSet)
revit.uidoc.RefreshActiveView()