<?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: stuck in BuiltInCategory enum in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/stuck-in-builtincategory-enum/m-p/10654592#M23465</link>
    <description>&lt;P&gt;Hi Ahmed,&lt;BR /&gt;as shown in your screenshots, form1.selectedcategory is a&amp;nbsp;&lt;STRONG&gt;String&lt;/STRONG&gt; type variable,&lt;BR /&gt;but the&amp;nbsp;&lt;A href="https://www.revitapidocs.com/2022/19cacc45-078a-2b57-b454-bccf6aa711b8.htm" target="_blank" rel="noopener"&gt;ElementCategoryFilter()&lt;/A&gt;&amp;nbsp;Constructor takes a &lt;A href="https://www.revitapidocs.com/2022/ba1c5b30-242f-5fdc-8ea9-ec3b61e6e722.htm" target="_blank" rel="noopener"&gt;BuiltInCategory&lt;/A&gt;&amp;nbsp;enum value!&lt;BR /&gt;so what you need is to convert your &lt;STRONG&gt;string&lt;/STRONG&gt; to a &lt;STRONG&gt;BuiltInCategory&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp;enum value,&lt;BR /&gt;you can try this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;BuiltInCategory BIC = (BuiltInCategory) BuiltInCategory.Parse(typeof(BuiltInCategory), form1.selectedcategory) ;
ElementCategoryFilter f = new ElementCategoryFilter(BIC);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Note that&amp;nbsp;&lt;STRONG&gt;form1.selectedcategory&amp;nbsp;&lt;/STRONG&gt;must be equal to the enum string value not the direct Revit category name, e.g.&lt;BR /&gt;Revit category name : "StructuralFraming"&lt;BR /&gt;enum string value : "OST_StructuralFraming"&lt;BR /&gt;you must use&amp;nbsp;"OST_StructuralFraming" not&amp;nbsp;"StructuralFraming"!&lt;BR /&gt;to get that you can make a dictionary to convert the value of the string&lt;BR /&gt;this link will help you a lot to achieve this:&lt;BR /&gt;&amp;nbsp;&lt;A href="https://docs.google.com/spreadsheets/d/1uNa77XYLjeN-1c63gsX6C5D5Pvn_3ZB4B0QMgPeloTw/edit#gid=1549586957" target="_blank" rel="noopener"&gt;https://docs.google.com/spreadsheets/....&lt;/A&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I hope that will help you!&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 29 Sep 2021 09:19:31 GMT</pubDate>
    <dc:creator>Omar_Amen</dc:creator>
    <dc:date>2021-09-29T09:19:31Z</dc:date>
    <item>
      <title>stuck in BuiltInCategory enum</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/stuck-in-builtincategory-enum/m-p/10653899#M23464</link>
      <description>&lt;P&gt;i have problem in convert 'user category selected' to 'item in BuiltInCategory enum'&lt;/P&gt;&lt;P&gt;thanks for your help ...&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-center" image-alt="Capture1.PNG" style="width: 536px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/970976iA3C22E73573E0491/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture1.PNG" alt="Capture1.PNG" /&gt;&lt;/span&gt;&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-center" image-alt="Capture2.PNG" style="width: 615px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/970977i67EF33531D1E2A0E/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture2.PNG" alt="Capture2.PNG" /&gt;&lt;/span&gt;&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-center" image-alt="Capture3.PNG" style="width: 842px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/970978i551FC3EB88FBBE29/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture3.PNG" alt="Capture3.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Sep 2021 01:24:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/stuck-in-builtincategory-enum/m-p/10653899#M23464</guid>
      <dc:creator>ahmed.samy661993</dc:creator>
      <dc:date>2021-09-29T01:24:43Z</dc:date>
    </item>
    <item>
      <title>Re: stuck in BuiltInCategory enum</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/stuck-in-builtincategory-enum/m-p/10654592#M23465</link>
      <description>&lt;P&gt;Hi Ahmed,&lt;BR /&gt;as shown in your screenshots, form1.selectedcategory is a&amp;nbsp;&lt;STRONG&gt;String&lt;/STRONG&gt; type variable,&lt;BR /&gt;but the&amp;nbsp;&lt;A href="https://www.revitapidocs.com/2022/19cacc45-078a-2b57-b454-bccf6aa711b8.htm" target="_blank" rel="noopener"&gt;ElementCategoryFilter()&lt;/A&gt;&amp;nbsp;Constructor takes a &lt;A href="https://www.revitapidocs.com/2022/ba1c5b30-242f-5fdc-8ea9-ec3b61e6e722.htm" target="_blank" rel="noopener"&gt;BuiltInCategory&lt;/A&gt;&amp;nbsp;enum value!&lt;BR /&gt;so what you need is to convert your &lt;STRONG&gt;string&lt;/STRONG&gt; to a &lt;STRONG&gt;BuiltInCategory&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp;enum value,&lt;BR /&gt;you can try this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;BuiltInCategory BIC = (BuiltInCategory) BuiltInCategory.Parse(typeof(BuiltInCategory), form1.selectedcategory) ;
ElementCategoryFilter f = new ElementCategoryFilter(BIC);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Note that&amp;nbsp;&lt;STRONG&gt;form1.selectedcategory&amp;nbsp;&lt;/STRONG&gt;must be equal to the enum string value not the direct Revit category name, e.g.&lt;BR /&gt;Revit category name : "StructuralFraming"&lt;BR /&gt;enum string value : "OST_StructuralFraming"&lt;BR /&gt;you must use&amp;nbsp;"OST_StructuralFraming" not&amp;nbsp;"StructuralFraming"!&lt;BR /&gt;to get that you can make a dictionary to convert the value of the string&lt;BR /&gt;this link will help you a lot to achieve this:&lt;BR /&gt;&amp;nbsp;&lt;A href="https://docs.google.com/spreadsheets/d/1uNa77XYLjeN-1c63gsX6C5D5Pvn_3ZB4B0QMgPeloTw/edit#gid=1549586957" target="_blank" rel="noopener"&gt;https://docs.google.com/spreadsheets/....&lt;/A&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I hope that will help you!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Sep 2021 09:19:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/stuck-in-builtincategory-enum/m-p/10654592#M23465</guid>
      <dc:creator>Omar_Amen</dc:creator>
      <dc:date>2021-09-29T09:19:31Z</dc:date>
    </item>
    <item>
      <title>Re: stuck in BuiltInCategory enum</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/stuck-in-builtincategory-enum/m-p/10654927#M23466</link>
      <description>&lt;P&gt;what kind of string do you use in your ComboBox? (ex : "OST_Walls" or "Walls"?). If you use the first one, you have to parse the built in category like &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/8594778"&gt;@Omar_Amen&lt;/a&gt;&amp;nbsp;said.&amp;nbsp; &lt;SPAN class="UserName lia-user-name lia-user-rank-Enthusiast lia-component-message-view-widget-author-username"&gt;If you use the second one (category name), you can iterate over the built in category enumeration, get their names and check if it's the same as the combo box value.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;BuiltInCategory BuiltInCategoryFromName(Document doc, string category_name)
{
    BuiltInCategory ost = BuiltInCategory.INVALID;
    Categories categories = doc.Settings.Categories;
    foreach (BuiltInCategory bic in System.Enum.GetValues(typeof(BuiltInCategory)))
    {
        try
        {         
            if (categories.get_Item(bic).Name == category_name)
            {
                ost = bic;
                break;
            }
        }
        catch
        {
        }
    }
    return ost;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Sep 2021 12:13:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/stuck-in-builtincategory-enum/m-p/10654927#M23466</guid>
      <dc:creator>guillain.jolivet</dc:creator>
      <dc:date>2021-09-29T12:13:15Z</dc:date>
    </item>
    <item>
      <title>Re: stuck in BuiltInCategory enum</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/stuck-in-builtincategory-enum/m-p/10655672#M23467</link>
      <description>&lt;P&gt;&lt;SPAN class=""&gt;it's working&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Thank you dear&amp;nbsp;&lt;A href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/8594778" target="_self"&gt;&lt;SPAN class=""&gt;omaramen&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Sep 2021 16:41:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/stuck-in-builtincategory-enum/m-p/10655672#M23467</guid>
      <dc:creator>ahmed.samy661993</dc:creator>
      <dc:date>2021-09-29T16:41:22Z</dc:date>
    </item>
  </channel>
</rss>

