<?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: How to avoid getting sub element when using FilteredElementCollector to retrieve all elements? in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-avoid-getting-quot-sub-element-in-an-element-quot-when/m-p/13655052#M10</link>
    <description>&lt;DIV class=""&gt;Yes, I can filter out this sub element that I know BuiltInCategory, but this is not a universal solution and I can't possibly list all the BuiltInCategories of all sub element&lt;/DIV&gt;</description>
    <pubDate>Thu, 29 May 2025 00:14:43 GMT</pubDate>
    <dc:creator>tumbleweed1024</dc:creator>
    <dc:date>2025-05-29T00:14:43Z</dc:date>
    <item>
      <title>How to avoid getting "sub element in an element" when getting all elements?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-avoid-getting-quot-sub-element-in-an-element-quot-when/m-p/13653602#M8</link>
      <description>&lt;P&gt;Hello everyone.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;I use the following code to get all the elements with geometry.&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;PRE&gt;List&amp;lt;Element&amp;gt; mainModeElems = new List&amp;lt;Element&amp;gt;();
FilteredElementCollector collector = new FilteredElementCollector(Document);
ICollection&amp;lt;Element&amp;gt; allElements = collector.WhereElementIsNotElementType().ToElements();
Options geoOptions = new Options();
foreach (Element element in allElements)
{
    GeometryElement geomElement = element.get_Geometry(geoOptions);
    if (geomElement != null)
    {
        mainModeElems.Add(element);
    }
}​&lt;/PRE&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;But this will collect sub element like OST_StairsRuns, OST_RailingTopRail, OST_StairsRailingBaluster and mullions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="tumbleweed1024_0-1748429804619.png" style="width: 346px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1537997i4B0117061AE65820/image-dimensions/346x219?v=v2" width="346" height="219" role="button" title="tumbleweed1024_0-1748429804619.png" alt="tumbleweed1024_0-1748429804619.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="tumbleweed1024_2-1748429877448.png" style="width: 346px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1537999i08CF2FC7C0A21D94/image-dimensions/346x259?v=v2" width="346" height="259" role="button" title="tumbleweed1024_2-1748429877448.png" alt="tumbleweed1024_2-1748429877448.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't need these elements, and these elements cause the ElementIntersectsElementFilter to throw an exception stating "The category of the element is not supported for element intersection filters."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How to filter out these sub elements? I haven't found any differences in attributes between them and the regular overall elements. Now I'm trying to use element.ArePhasesModifiable() for filtering, which seems to work, but could this cause any errors or lead to the omission of certain elements?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you all.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 May 2025 00:27:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/how-to-avoid-getting-quot-sub-element-in-an-element-quot-when/m-p/13653602#M8</guid>
      <dc:creator>tumbleweed1024</dc:creator>
      <dc:date>2025-05-29T00:27:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to avoid getting sub element when using FilteredElementCollector to retrieve all elements?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-avoid-getting-quot-sub-element-in-an-element-quot-when/m-p/13654175#M9</link>
      <description>&lt;P&gt;You can use a ElementMultiCategoryFilter with the inverted overload, like this:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;				var catsToExclude = new ElementMulticategoryFilter(new BuiltInCategory[]{BuiltInCategory.OST_StairsRuns,BuiltInCategory.OST_RailingTopRail},true);
				var elementsWithoutAboveCategories = new FilteredElementCollector(Doc).WhereElementIsNotElementType().WherePasses(catsToExclude);&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 28 May 2025 14:30:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/how-to-avoid-getting-quot-sub-element-in-an-element-quot-when/m-p/13654175#M9</guid>
      <dc:creator>rcrdzmmrmnn</dc:creator>
      <dc:date>2025-05-28T14:30:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to avoid getting sub element when using FilteredElementCollector to retrieve all elements?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-avoid-getting-quot-sub-element-in-an-element-quot-when/m-p/13655052#M10</link>
      <description>&lt;DIV class=""&gt;Yes, I can filter out this sub element that I know BuiltInCategory, but this is not a universal solution and I can't possibly list all the BuiltInCategories of all sub element&lt;/DIV&gt;</description>
      <pubDate>Thu, 29 May 2025 00:14:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/how-to-avoid-getting-quot-sub-element-in-an-element-quot-when/m-p/13655052#M10</guid>
      <dc:creator>tumbleweed1024</dc:creator>
      <dc:date>2025-05-29T00:14:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to avoid getting "sub element in an element" when getting all elements?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-avoid-getting-quot-sub-element-in-an-element-quot-when/m-p/13655810#M11</link>
      <description>&lt;DIV class=""&gt;Can someone reply to me? I'd really appreciate it&amp;nbsp; : D&lt;/DIV&gt;</description>
      <pubDate>Thu, 29 May 2025 09:11:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/how-to-avoid-getting-quot-sub-element-in-an-element-quot-when/m-p/13655810#M11</guid>
      <dc:creator>tumbleweed1024</dc:creator>
      <dc:date>2025-05-29T09:11:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to avoid getting sub element when using FilteredElementCollector to retrieve all elements?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-avoid-getting-quot-sub-element-in-an-element-quot-when/m-p/13656128#M12</link>
      <description>&lt;P&gt;For familyInstances it should be easy, using the property SuperComponent. If this property is null, it does not have a parent element.&lt;BR /&gt;You mentioned that you want to filter them out in order to use the ElementIntersectElement filter, and some of them throw an exception.&lt;BR /&gt;My best guess is, create a List&amp;lt;BuiltinCategory&amp;gt; and everytime you catch that exception you add the failed category to that list and after all elements iterate over the list,&amp;nbsp; print the listed categories and use for tweaking the code. Even better than a list is a Hashset as it won't add repeated categories. Unfortunately, this is the best I can think of.&lt;/P&gt;</description>
      <pubDate>Thu, 29 May 2025 12:48:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/how-to-avoid-getting-quot-sub-element-in-an-element-quot-when/m-p/13656128#M12</guid>
      <dc:creator>rcrdzmmrmnn</dc:creator>
      <dc:date>2025-05-29T12:48:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to avoid getting "sub element in an element" when getting all elements?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-avoid-getting-quot-sub-element-in-an-element-quot-when/m-p/13656938#M13</link>
      <description>&lt;P&gt;you could go the"unprofessional" route and use a try/catch, something like this:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt; try
 {
     //element intersections code
     //when it throws exceptions, it goes to catch, but you dont need to do anything about it, essentially skipping the elements you dont want.
 }
 catch { }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 May 2025 22:13:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/how-to-avoid-getting-quot-sub-element-in-an-element-quot-when/m-p/13656938#M13</guid>
      <dc:creator>ctm_mka</dc:creator>
      <dc:date>2025-05-29T22:13:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to avoid getting "sub element in an element" when getting all elements?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-avoid-getting-quot-sub-element-in-an-element-quot-when/m-p/13657016#M430</link>
      <description>&lt;P&gt;Yeah, basically that's what I've said, but then, save the failed categories to improve the code in order to the future runs don't even pass the failing categories, because some categories like mullions will have A LOT of elements(and obviously, a lot of exceptions).&lt;/P&gt;</description>
      <pubDate>Thu, 29 May 2025 23:30:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/how-to-avoid-getting-quot-sub-element-in-an-element-quot-when/m-p/13657016#M430</guid>
      <dc:creator>rcrdzmmrmnn</dc:creator>
      <dc:date>2025-05-29T23:30:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to avoid getting "sub element in an element" when getting all elements?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-avoid-getting-quot-sub-element-in-an-element-quot-when/m-p/13657177#M11629</link>
      <description>&lt;DIV class=""&gt;&lt;DIV class=""&gt;Well, thank you, it looks like Revit doesn't provide an API that can distinguish sub elements.&lt;/DIV&gt;&lt;DIV class=""&gt;If there is a problem with the ArePhasesModifiable() method, will have to manually write a list of categories&amp;nbsp; : (&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 02 Jun 2025 00:48:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/how-to-avoid-getting-quot-sub-element-in-an-element-quot-when/m-p/13657177#M11629</guid>
      <dc:creator>tumbleweed1024</dc:creator>
      <dc:date>2025-06-02T00:48:17Z</dc:date>
    </item>
  </channel>
</rss>

