Message 1 of 5

Not applicable
04-13-2021
08:14 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm trying to get all fiters in view template, and the code below works for some projects, but not all.
exception: the view type does not support visiblity/graphics overrides
what i have found is, view.GetFilters() method will not return the view template in which there's no filters. for instance, i have template 1,2,3, and only the 3 has no filters, when i export to excel , there are only template 1 and 2.
but when all my templates have no filters in them, it returns the exception ---the view type does not support visiblity/graphics overrides
is there any way to check if view template contains filters or not first ?
or maybe better way to handle this exception? Thx
foreach (View view in ViewTemp)
{
string _Id, _Name, _ClassName, _ViewtempName;
if (view.IsTemplate)
{
ICollection<ElementId> filterIds = view.GetFilters();
foreach (ElementId id in filterIds)
{
Element filter = doc.GetElement(id);
_Id = filter.Id.ToString();
_Name = filter.Name;
_ClassName = filter.GetType().Name;
_ViewtempName = view.Name;
object[] FilterData = { _Id, _Name, _ClassName, _ViewtempName };
FilterDataList.Add(FilterData);
}
}
}
Solved! Go to Solution.