<?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 How to get imported Categories in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-get-imported-categories/m-p/6464633#M63809</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In Revit Graphics/Visibility Overrides dialog, I can see the Imported Categories tab.&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://forums.autodesk.com/t5/image/serverpage/image-id/258615i5ABDB78F0DEEEAE7/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="2016-07-28_1818.png" title="2016-07-28_1818.png" /&gt;&lt;/P&gt;&lt;P&gt;In API Category has a property&amp;nbsp;&lt;EM&gt;CategoryType&lt;/EM&gt; which is Enum with the following values:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Invalid&lt;/LI&gt;&lt;LI&gt;Model&lt;/LI&gt;&lt;LI&gt;Annotation&lt;/LI&gt;&lt;LI&gt;Internal&lt;/LI&gt;&lt;LI&gt;AnalyticalModel&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Looks like CategoryType corresponds the tabs in Dialog, but not. Imported Categories also have &lt;EM&gt;CategoryType = CategoryType.Model,&lt;/EM&gt; but not appear in the Model Categories tab.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to find out whether a category is Imported or not?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I actually found two ways. The first on is implicit. I just looked into RevitLookup and checked the properties of Imported category:&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://forums.autodesk.com/t5/image/serverpage/image-id/258618iDB803BF4928F27D2/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="2016-07-28_1823.png" title="2016-07-28_1823.png" /&gt;&lt;/P&gt;&lt;P&gt;I noticed the following:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Category.Id is not BuiltInCategory, i.e. value &amp;gt; 0&lt;/LI&gt;&lt;LI&gt;Properties&amp;nbsp;AllowsBoundParameters,&amp;nbsp;CanAddSubcategory,&amp;nbsp;HasMaterialQuantities and&amp;nbsp;IsCuttable are always false for imported categories.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;As a result, I cretaed the extension method:&lt;/P&gt;&lt;PRE&gt;    public static class CategoryExtenstions
    {
        public static bool IsImportedCategory(this Category category)
        {
            if (Enum.IsDefined(typeof(BuiltInCategory), category.Id.IntegerValue))
                return false;

            if (category.Id.IntegerValue &amp;lt; -1)
                return false;

            return category.AllowsBoundParameters == false &amp;amp;&amp;amp;
                category.CanAddSubcategory == false &amp;amp;&amp;amp;
                category.HasMaterialQuantities == false &amp;amp;&amp;amp;
                category.IsCuttable == false;
        }
    }&lt;/PRE&gt;&lt;P&gt;It works. I tested it only for couple models. But want to now is it reliable method or not?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The second one is more complicated, but gave for me the same result.&lt;/P&gt;&lt;P&gt;Searching by keyword "Imported" in Revit API help, I've found the only enum member:&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://forums.autodesk.com/t5/image/serverpage/image-id/258619iD66D39336F35923A/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="2016-07-28_1829.png" title="2016-07-28_1829.png" /&gt;&lt;/P&gt;&lt;P&gt;Sounds like this is exactly that I need.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This enum member is related with DWG Export Options. In UI we can find it in DWG Export Settings dialog:&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://forums.autodesk.com/t5/image/serverpage/image-id/258621i8B46DA8D49A966F7/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="2016-07-28_1831.png" title="2016-07-28_1831.png" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will not provide the code snippet for this approach. It is really much complicated and gives the same result.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Are there other ways to find out Imported Categories? Definitely internally Revit knows about that, but how to get this info in API? Or I have already found this way? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Victor.&lt;/P&gt;</description>
    <pubDate>Thu, 28 Jul 2016 13:34:18 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2016-07-28T13:34:18Z</dc:date>
    <item>
      <title>How to get imported Categories</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-get-imported-categories/m-p/6464633#M63809</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In Revit Graphics/Visibility Overrides dialog, I can see the Imported Categories tab.&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://forums.autodesk.com/t5/image/serverpage/image-id/258615i5ABDB78F0DEEEAE7/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="2016-07-28_1818.png" title="2016-07-28_1818.png" /&gt;&lt;/P&gt;&lt;P&gt;In API Category has a property&amp;nbsp;&lt;EM&gt;CategoryType&lt;/EM&gt; which is Enum with the following values:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Invalid&lt;/LI&gt;&lt;LI&gt;Model&lt;/LI&gt;&lt;LI&gt;Annotation&lt;/LI&gt;&lt;LI&gt;Internal&lt;/LI&gt;&lt;LI&gt;AnalyticalModel&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Looks like CategoryType corresponds the tabs in Dialog, but not. Imported Categories also have &lt;EM&gt;CategoryType = CategoryType.Model,&lt;/EM&gt; but not appear in the Model Categories tab.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to find out whether a category is Imported or not?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I actually found two ways. The first on is implicit. I just looked into RevitLookup and checked the properties of Imported category:&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://forums.autodesk.com/t5/image/serverpage/image-id/258618iDB803BF4928F27D2/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="2016-07-28_1823.png" title="2016-07-28_1823.png" /&gt;&lt;/P&gt;&lt;P&gt;I noticed the following:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Category.Id is not BuiltInCategory, i.e. value &amp;gt; 0&lt;/LI&gt;&lt;LI&gt;Properties&amp;nbsp;AllowsBoundParameters,&amp;nbsp;CanAddSubcategory,&amp;nbsp;HasMaterialQuantities and&amp;nbsp;IsCuttable are always false for imported categories.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;As a result, I cretaed the extension method:&lt;/P&gt;&lt;PRE&gt;    public static class CategoryExtenstions
    {
        public static bool IsImportedCategory(this Category category)
        {
            if (Enum.IsDefined(typeof(BuiltInCategory), category.Id.IntegerValue))
                return false;

            if (category.Id.IntegerValue &amp;lt; -1)
                return false;

            return category.AllowsBoundParameters == false &amp;amp;&amp;amp;
                category.CanAddSubcategory == false &amp;amp;&amp;amp;
                category.HasMaterialQuantities == false &amp;amp;&amp;amp;
                category.IsCuttable == false;
        }
    }&lt;/PRE&gt;&lt;P&gt;It works. I tested it only for couple models. But want to now is it reliable method or not?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The second one is more complicated, but gave for me the same result.&lt;/P&gt;&lt;P&gt;Searching by keyword "Imported" in Revit API help, I've found the only enum member:&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://forums.autodesk.com/t5/image/serverpage/image-id/258619iD66D39336F35923A/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="2016-07-28_1829.png" title="2016-07-28_1829.png" /&gt;&lt;/P&gt;&lt;P&gt;Sounds like this is exactly that I need.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This enum member is related with DWG Export Options. In UI we can find it in DWG Export Settings dialog:&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://forums.autodesk.com/t5/image/serverpage/image-id/258621i8B46DA8D49A966F7/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="2016-07-28_1831.png" title="2016-07-28_1831.png" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will not provide the code snippet for this approach. It is really much complicated and gives the same result.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Are there other ways to find out Imported Categories? Definitely internally Revit knows about that, but how to get this info in API? Or I have already found this way? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Victor.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jul 2016 13:34:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/how-to-get-imported-categories/m-p/6464633#M63809</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-07-28T13:34:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to get imported Categories</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-get-imported-categories/m-p/6475802#M63810</link>
      <description>&lt;P&gt;Dear Victor,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for deep investigation and sharing!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yet another approach you may consider to try is&amp;nbsp;&lt;SPAN&gt;ExternalFileReference related:&amp;nbsp;&lt;/SPAN&gt;the imported instances are ExternalFileReference, you can use ExternalFileReferenceType to distinguish them. ExternalFileUtils.GetAllExternalFileReferences() can get all the ExternalFileReference's Id.&lt;/P&gt;
&lt;P&gt;Following&amp;nbsp;is simple sample snippet, do you think this is useful?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;private void GetExternalFileCategory()&lt;BR /&gt; {&lt;BR /&gt; string info = null;&lt;BR /&gt; ICollection&amp;lt;ElementId&amp;gt; ids = ExternalFileUtils.GetAllExternalFileReferences(doc);&lt;BR /&gt; foreach(ElementId id in ids)&lt;BR /&gt; {&lt;BR /&gt; Element elem = doc.GetElement(id);&lt;BR /&gt; if(elem.Category!= null)&lt;BR /&gt; info += elem.Category.Name + "\n";&lt;BR /&gt; }&lt;BR /&gt; MessageBox.Show(info);&lt;BR /&gt; }&lt;/P&gt;</description>
      <pubDate>Wed, 03 Aug 2016 14:54:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/how-to-get-imported-categories/m-p/6475802#M63810</guid>
      <dc:creator>JimJia</dc:creator>
      <dc:date>2016-08-03T14:54:34Z</dc:date>
    </item>
  </channel>
</rss>

