<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: FilteredElementCollector -&amp;gt; get all instances except of category X in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/filteredelementcollector-gt-get-all-instances-except-of-category/m-p/8571325#M44436</link>
    <description>&lt;P&gt;I do this now but there has to be a cleaner way...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;public ICollection&amp;lt;Element&amp;gt; CollectFamilyInstances(Document doc)
        {
            FilteredElementCollector collector
                = new FilteredElementCollector(doc);

            ICollection&amp;lt;Element&amp;gt; collection
              = collector.OfClass(typeof(FamilyInstance))
                .ToElements();

            ICollection&amp;lt;Element&amp;gt; collection2 = new List&amp;lt;Element&amp;gt;();

            foreach (Element e in collection)
            {
                if (!e.Category.Equals(BuiltInCategory.OST_TitleBlocks))
                {
                    collection2.Add(e);
                }
            }
            
            return collection2;
        }&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thanks for any extra advice on this!&lt;/P&gt;</description>
    <pubDate>Mon, 04 Feb 2019 14:24:21 GMT</pubDate>
    <dc:creator>jnoordzij</dc:creator>
    <dc:date>2019-02-04T14:24:21Z</dc:date>
    <item>
      <title>FilteredElementCollector -&gt; get all instances except of category X</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/filteredelementcollector-gt-get-all-instances-except-of-category/m-p/8571199#M44435</link>
      <description>&lt;P&gt;I am filtering for FamilInstances in a doc using FilteredElementCollector.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to get all family instances, except the titleblocks.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;public ICollection&amp;lt;Element&amp;gt; CollectFamilyInstances(Document doc)
        {
            FilteredElementCollector collector
                = new FilteredElementCollector(doc);

            ICollection&amp;lt;Element&amp;gt; collection
              = collector.OfClass(typeof(FamilyInstance))
                .ToElements();

            return collection;
        }&lt;/PRE&gt;
&lt;P&gt;How can i apply a filter over this collection so that instances of category OST_TitleBlocks are omitted from this collection?&lt;/P&gt;</description>
      <pubDate>Mon, 04 Feb 2019 13:42:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/filteredelementcollector-gt-get-all-instances-except-of-category/m-p/8571199#M44435</guid>
      <dc:creator>jnoordzij</dc:creator>
      <dc:date>2019-02-04T13:42:07Z</dc:date>
    </item>
    <item>
      <title>Re: FilteredElementCollector -&gt; get all instances except of category X</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/filteredelementcollector-gt-get-all-instances-except-of-category/m-p/8571325#M44436</link>
      <description>&lt;P&gt;I do this now but there has to be a cleaner way...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;public ICollection&amp;lt;Element&amp;gt; CollectFamilyInstances(Document doc)
        {
            FilteredElementCollector collector
                = new FilteredElementCollector(doc);

            ICollection&amp;lt;Element&amp;gt; collection
              = collector.OfClass(typeof(FamilyInstance))
                .ToElements();

            ICollection&amp;lt;Element&amp;gt; collection2 = new List&amp;lt;Element&amp;gt;();

            foreach (Element e in collection)
            {
                if (!e.Category.Equals(BuiltInCategory.OST_TitleBlocks))
                {
                    collection2.Add(e);
                }
            }
            
            return collection2;
        }&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thanks for any extra advice on this!&lt;/P&gt;</description>
      <pubDate>Mon, 04 Feb 2019 14:24:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/filteredelementcollector-gt-get-all-instances-except-of-category/m-p/8571325#M44436</guid>
      <dc:creator>jnoordzij</dc:creator>
      <dc:date>2019-02-04T14:24:21Z</dc:date>
    </item>
    <item>
      <title>Re: FilteredElementCollector -&gt; get all instances except of category X</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/filteredelementcollector-gt-get-all-instances-except-of-category/m-p/8571354#M44437</link>
      <description>&lt;P&gt;Got it to work!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;public ICollection&amp;lt;Element&amp;gt; CollectFamilyInstances(Document doc)
        {
            FilteredElementCollector collector
                = new FilteredElementCollector(doc);

            ElementCategoryFilter fi = new ElementCategoryFilter(BuiltInCategory.OST_TitleBlocks, true);

            ICollection&amp;lt;Element&amp;gt; collection
              = collector.OfClass(typeof(FamilyInstance)).WherePasses(fi)
                .ToElements();

            return collection;
        }&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Feb 2019 14:30:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/filteredelementcollector-gt-get-all-instances-except-of-category/m-p/8571354#M44437</guid>
      <dc:creator>jnoordzij</dc:creator>
      <dc:date>2019-02-04T14:30:41Z</dc:date>
    </item>
    <item>
      <title>Re: FilteredElementCollector -&gt; get all instances except of category X</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/filteredelementcollector-gt-get-all-instances-except-of-category/m-p/8571377#M44438</link>
      <description>&lt;P&gt;Not tested, but maybe using quick filter is what you are looking for (if you want just titleblocks category):&lt;/P&gt;
&lt;PRE&gt;ElementCategoryFilter titleblockfilter = new ElementCategoryFilter(BuiltInCategory.OST_TitleBlocks);
ICollection&amp;lt;Element&amp;gt; collection
              = collector.OfClass(typeof(FamilyInstance))
                .WherePasses(titleblockfilter)
                .ToElements();&lt;/PRE&gt;</description>
      <pubDate>Mon, 04 Feb 2019 14:36:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/filteredelementcollector-gt-get-all-instances-except-of-category/m-p/8571377#M44438</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-02-04T14:36:50Z</dc:date>
    </item>
    <item>
      <title>Re: FilteredElementCollector -&gt; get all instances except of category X</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/filteredelementcollector-gt-get-all-instances-except-of-category/m-p/8573163#M44439</link>
      <description>&lt;P&gt;HI&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3093921"&gt;@jnoordzij&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ExclusionFilter Class helps you to filter elements by excluding particular elements.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.revitapidocs.com/2015/28581bc9-42ad-9178-edcc-e33f42090bc9.htm" target="_blank" rel="noopener"&gt;Exclusion Filter Class&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;FilteredElementCollector Collector = new FilteredElementCollector(doc).OfClass(typeof(FamilyInstance)).WhereElementIsNotElementType();
IList&amp;lt;ElementId&amp;gt; eids = Collector.ToElementIds() as IList&amp;lt;ElementId&amp;gt;;&lt;BR /&gt;
ICollection&amp;lt;ElementId&amp;gt; exclude_elements = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_TitleBlocks).WhereElementIsNotElementType().ToElementIds() as ICollection&amp;lt;ElementId&amp;gt;;

ExclusionFilter EF = new ExclusionFilter(exclude_elements);
IList&amp;lt;ElementId&amp;gt; elementsAfterExclusion = Collector.WherePasses(EF).OfClass(typeof(FamilyInstance)).ToElementIds() as IList&amp;lt;ElementId&amp;gt;;&lt;/PRE&gt;
&lt;P&gt;If this helped solve your problem please mark it as solution, so other users can get this solutions as well&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://forums.autodesk.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Feb 2019 05:59:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/filteredelementcollector-gt-get-all-instances-except-of-category/m-p/8573163#M44439</guid>
      <dc:creator>naveen.kumar.t</dc:creator>
      <dc:date>2019-02-05T05:59:49Z</dc:date>
    </item>
    <item>
      <title>Re: FilteredElementCollector -&gt; get all instances except of category X</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/filteredelementcollector-gt-get-all-instances-except-of-category/m-p/8573493#M44440</link>
      <description>&lt;P&gt;In conclusion of this thread:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I haven't checked the solution provided by&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5661631"&gt;@naveen.kumar.t&lt;/a&gt;&amp;nbsp;, since I found a working solution beforehand, but that solution might also work.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My own solution was that the ElementCategoryFilter has an additional boolean option that&amp;nbsp;&lt;SPAN&gt;provides the option to match all elements which are NOT of the given category. So an "&lt;STRONG&gt;invert&lt;/STRONG&gt;" boolean. Hence the (invert=) "true" at the end of&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;ElementCategoryFilter fi = new ElementCategoryFilter(BuiltInCategory.OST_TitleBlocks, true);&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2019 05 02 - 01.JPG" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/599351iB4DAB81CC1C6A3CB/image-size/large?v=v2&amp;amp;px=999" role="button" title="2019 05 02 - 01.JPG" alt="2019 05 02 - 01.JPG" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Feb 2019 09:53:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/filteredelementcollector-gt-get-all-instances-except-of-category/m-p/8573493#M44440</guid>
      <dc:creator>jnoordzij</dc:creator>
      <dc:date>2019-02-05T09:53:58Z</dc:date>
    </item>
  </channel>
</rss>

