Beispiel #1
0
def get_all_tag_elements(tag):
    """Get all elements of given tag.

    Args:
        tag (Tag): tag object

    Returns:
        list[DB.Element]: list of elements in that tag
    """
    # does not work in < 2016
    # spid = framework.Guid('24353a46-1313-46a4-a779-d33ffe9353ab')
    # pid = DB.SharedParameterElement.Lookup(revit.doc, spid)
    # pp = DB.ParameterValueProvider(pid)
    # pe = DB.FilterStringEquals()
    # vrule = DB.FilterDoubleRule(pp, pe, tag_id, True)
    # param_filter = DB.ElementParameterFilter(vrule)
    # elements = DB.FilteredElementCollector(revit.doc) \
    #           .WherePasses(param_filter) \
    #           .ToElementIds()
    skip_cats = [query.get_category(x) for x in SCOPE_SKIP_CATEGORIES]
    skip_catids = [x.Id for x in skip_cats if x is not None]
    return [
        x for x in query.get_all_elements() if tag in extract_tags(x)
        and x.Category is not None and x.Category.Id not in skip_catids
    ]
Beispiel #2
0
def pick_element_by_category(cat_name_or_builtin, message=''):
    category = query.get_category(cat_name_or_builtin)
    if category:
        pick_filter = PickByCategorySelectionFilter(category.Id)
        return _pick_obj(UI.Selection.ObjectType.Element,
                         message,
                         selection_filter=pick_filter)
    else:
        raise PyRevitException("Can not determine category id from: {}".format(
            cat_name_or_builtin))