I’m making a quick helper tool which will just temproraly hide a predefined list of categories in an active view.
I’ve tried this a few ways but get stuck with a similar error, HideCategoriesTemporary() is giving me similar errors
passing a list of elements:
expected ICollection[ElementId], got list
Heres is a solution to it,
the two spots that i got stuck on were
Thinking that Type in List[Type] would need to be the CLR type of the elements in the list
Thnking that I’d need to have a ListType instead of just passing the categories into it right away
from System.Collections.Generic import List
doc = __revit__.ActiveUIDocument.Document
doc.ActiveView.TemporaryViewModes.DeactivateAllModes()
cats = [
DB.ElementId(DB.BuiltInCategory.OST_Walls),
DB.ElementId(DB.BuiltInCategory.OST_Doors),
# list of other categories...
]
cat_collection = List[DB.ElementId](cats)
doc.ActiveView.HideCategoriesTemporary(cat_collection)
@eimhin Something similar I did to hide/unhide all georef points in active view
from pyrevit import HOST_APP, DB, revit
from System.Collections.Generic import List
active_view = HOST_APP.active_view
catsId = [
DB.ElementId(DB.BuiltInCategory.OST_IOS_GeoSite),
DB.ElementId(DB.BuiltInCategory.OST_SharedBasePoint),
DB.ElementId(DB.BuiltInCategory.OST_ProjectBasePoint)
]
cat_collection = List[DB.ElementId](catsId)
# get if category is hidden in active view
cats_visibility_status = []
for cat in cat_collection:
cats_visibility_status.append(active_view.GetCategoryHidden(cat))
with revit.Transaction('turn on Georeferenced Points'):
for cat in cat_collection:
if all(cats_visibility_status):
active_view.SetCategoryHidden(cat, False)
else:
active_view.SetCategoryHidden(cat, True)