<?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: Determine if element is ElementType in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/determine-if-element-is-elementtype/m-p/9713980#M32261</link>
    <description>&lt;P&gt;Here's a more Revit orientated approach you asked how a collector determines an ElementType but you can always pass a list of a single element into a collector and filter that:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Dim FEC As New FilteredElementCollector(element.Document, {element.Id}.ToList)
Dim B3 As Boolean = FEC.WhereElementIsElementType.ToElementIds.Count &amp;gt; 0&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can't do it in C# in this abbreviated fashion due to the need to use ICollection&amp;lt;T&amp;gt; directly (option Strict off in vb)&amp;nbsp; but you can do similar.&lt;/P&gt;</description>
    <pubDate>Thu, 27 Aug 2020 00:04:35 GMT</pubDate>
    <dc:creator>RPTHOMAS108</dc:creator>
    <dc:date>2020-08-27T00:04:35Z</dc:date>
    <item>
      <title>Determine if element is ElementType</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/determine-if-element-is-elementtype/m-p/9713330#M32259</link>
      <description>&lt;P&gt;I'm listening to the Application.DocumentChanged event and I would like to see if the element modified is an Instance or an ElementType. I'm currently doing the following but it doesn't quite satisfy all the conditions. I'm not native to Revit sorry if my terminology is off. How does the `FilterCollector.WhereElementIsElementType()` determine it's an ElementType?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;private static bool IsElementType(Element element)
{
    var typeId = element?.GetTypeId();
    if (typeId == null || typeId == ElementId.InvalidElementId)
    {
        if (!(element is Room) &amp;amp;&amp;amp; !(element is PipeSegment))
        {
            return true;
        }
    }    
    return false;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Aug 2020 16:35:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/determine-if-element-is-elementtype/m-p/9713330#M32259</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-08-26T16:35:00Z</dc:date>
    </item>
    <item>
      <title>Re: Determine if element is ElementType</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/determine-if-element-is-elementtype/m-p/9713423#M32260</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;//This will return false if type is ElementType but true if is derived from ElementType
bool Bl = element.GetType().IsSubclassOf(typeof(ElementType));

//This will return true if type is ElementType or is derived from ElementType
bool B2 = typeof(ElementType).IsAssignableFrom(element.GetType());&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Aug 2020 17:22:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/determine-if-element-is-elementtype/m-p/9713423#M32260</guid>
      <dc:creator>RPTHOMAS108</dc:creator>
      <dc:date>2020-08-26T17:22:31Z</dc:date>
    </item>
    <item>
      <title>Re: Determine if element is ElementType</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/determine-if-element-is-elementtype/m-p/9713980#M32261</link>
      <description>&lt;P&gt;Here's a more Revit orientated approach you asked how a collector determines an ElementType but you can always pass a list of a single element into a collector and filter that:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Dim FEC As New FilteredElementCollector(element.Document, {element.Id}.ToList)
Dim B3 As Boolean = FEC.WhereElementIsElementType.ToElementIds.Count &amp;gt; 0&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can't do it in C# in this abbreviated fashion due to the need to use ICollection&amp;lt;T&amp;gt; directly (option Strict off in vb)&amp;nbsp; but you can do similar.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Aug 2020 00:04:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/determine-if-element-is-elementtype/m-p/9713980#M32261</guid>
      <dc:creator>RPTHOMAS108</dc:creator>
      <dc:date>2020-08-27T00:04:35Z</dc:date>
    </item>
    <item>
      <title>Re: Determine if element is ElementType</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/determine-if-element-is-elementtype/m-p/9718174#M32262</link>
      <description>&lt;P&gt;Here's a simpler way of putting it.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;private static bool IsElementType(Element element)
{
    return element is ElementType;
}&lt;/LI-CODE&gt;&lt;P&gt;I'd suggest not even making a method for this and just using the&amp;nbsp;&lt;EM&gt;is&lt;/EM&gt; expression.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Aug 2020 21:09:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/determine-if-element-is-elementtype/m-p/9718174#M32262</guid>
      <dc:creator>mhannonQ65N2</dc:creator>
      <dc:date>2020-08-28T21:09:02Z</dc:date>
    </item>
    <item>
      <title>Re: Determine if element is ElementType</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/determine-if-element-is-elementtype/m-p/9718474#M32263</link>
      <description>&lt;P&gt;I use the "is" operator quite often in my work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is an online method which will give you the EType as a variable:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;if(element is ElementType EType)
{
    TaskDialog.Show("Type Name",EType.Name);
}&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 29 Aug 2020 05:08:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/determine-if-element-is-elementtype/m-p/9718474#M32263</guid>
      <dc:creator>Sean_Page</dc:creator>
      <dc:date>2020-08-29T05:08:01Z</dc:date>
    </item>
    <item>
      <title>Re: Determine if element is ElementType</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/determine-if-element-is-elementtype/m-p/9718612#M32264</link>
      <description>&lt;P&gt;Interesting to note that in VB the 'is' statement only returns true if the exact same type is compared. Since 'is' is used to check if two things are the same object instance.&amp;nbsp;The equivalent to the way it is used in C# seems to be:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Dim B1 As Boolean = TypeOf Element Is ElementType&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which is something I've never really used to be honest.&lt;/P&gt;</description>
      <pubDate>Sat, 29 Aug 2020 10:48:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/determine-if-element-is-elementtype/m-p/9718612#M32264</guid>
      <dc:creator>RPTHOMAS108</dc:creator>
      <dc:date>2020-08-29T10:48:38Z</dc:date>
    </item>
  </channel>
</rss>

