Quantcast
Channel: RevitNetAddinWizard & NavisworksNetAddinWizard
Viewing all articles
Browse latest Browse all 872

Revit .NET: Non-Filterable Revit Categories

$
0
0

We found out some Categories of Revit are not filterable as a side product when working on something else recently. It pretty surprised us. What about you?

It’s easy to sort out what Revit categories are not filterable. Here we go.

    using (StreamWriter sw = new StreamWriter(@"c:\temp\CategoriesCannotBeFiltered.txt"))
    {
        foreach (BuiltInCategory biCat in Enum.GetValues(typeof(BuiltInCategory)))
        {
            if (biCat != BuiltInCategory.INVALID)
            {
                FilteredElementCollector finalCollector = new FilteredElementCollector(CachedDoc);
                try
                {
                    ElementCategoryFilter filter1 = new ElementCategoryFilter(biCat);
                    finalCollector.WherePasses(filter1);
                }
                catch (Exception ex)
                {
                    sw.WriteLine(biCat + ": " + ex.Message);
                    continue;
                }
            }
        }
        sw.Close();
    }

Here is the output.

OST_MatchSiteComponent: The category was not valid for filtering.
Parameter name: categoryId
OST_MatchProfile: The category was not valid for filtering.
Parameter name: categoryId
OST_MatchDetail: The category was not valid for filtering.
Parameter name: categoryId
OST_MatchAnnotation: The category was not valid for filtering.
Parameter name: categoryId
OST_MatchModel: The category was not valid for filtering.
Parameter name: categoryId
OST_MatchAll: The category was not valid for filtering.
Parameter name: categoryId

So, the categories with the built-in category ids as OST_MatchSiteComponent, OST_MatchProfile, OST_MatchDetail, OST_MatchAnnotation, OST_MatchModel, and OST_MatchAll are not filterable (i.e. not valid for filtering). Not sure why only these few are not filterable, but it sounds good for us to keep them in mind when doing something like filtering or categorizing Revit elements.

Revit Addin Wizard (RevitAddinWizard) provides various wizards, coders and widgets to help program Revit addins. It can be downloaded from the Download link at the bottom of the blog index page.


Viewing all articles
Browse latest Browse all 872

Trending Articles