<?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 add a new category to an existing project parameter in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-add-a-new-category-to-an-existing-project-parameter/m-p/12035692#M11413</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt; string targetParamName = "测试";
BuiltInCategory newCategory = BuiltInCategory.OST_Ceilings;

DefinitionBindingMapIterator iter = document.ParameterBindings.ForwardIterator();
                while (iter.MoveNext())
                {
                    Definition def = iter.Key;
                    if (def.Name == targetParamName)
                    {
                        ElementBinding binding = iter.Current as ElementBinding;
                        CategorySet categories = binding.Categories;
                        using (Transaction t = new Transaction(document, "Insert Category"))
                        {
                            t.Start();
                            categories.Insert(document.Settings.Categories.get_Item(newCategory));
                            t.Commit();
                        }
                        break;
                    }
                }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This method does not add a new category to the specified project parameter. Although the members of binding.Categories increase every time the method is executed, there is no Test parameter in the Ceiling properties in the software.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Please tell me where the problem is, thank you&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 15 Jun 2023 09:35:25 GMT</pubDate>
    <dc:creator>434977268</dc:creator>
    <dc:date>2023-06-15T09:35:25Z</dc:date>
    <item>
      <title>How to add a new category to an existing project parameter</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-add-a-new-category-to-an-existing-project-parameter/m-p/12035692#M11413</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt; string targetParamName = "测试";
BuiltInCategory newCategory = BuiltInCategory.OST_Ceilings;

DefinitionBindingMapIterator iter = document.ParameterBindings.ForwardIterator();
                while (iter.MoveNext())
                {
                    Definition def = iter.Key;
                    if (def.Name == targetParamName)
                    {
                        ElementBinding binding = iter.Current as ElementBinding;
                        CategorySet categories = binding.Categories;
                        using (Transaction t = new Transaction(document, "Insert Category"))
                        {
                            t.Start();
                            categories.Insert(document.Settings.Categories.get_Item(newCategory));
                            t.Commit();
                        }
                        break;
                    }
                }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This method does not add a new category to the specified project parameter. Although the members of binding.Categories increase every time the method is executed, there is no Test parameter in the Ceiling properties in the software.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Please tell me where the problem is, thank you&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2023 09:35:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/how-to-add-a-new-category-to-an-existing-project-parameter/m-p/12035692#M11413</guid>
      <dc:creator>434977268</dc:creator>
      <dc:date>2023-06-15T09:35:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a new category to an existing project parameter</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-add-a-new-category-to-an-existing-project-parameter/m-p/12035794#M11414</link>
      <description>&lt;P&gt;@HI&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/12999619"&gt;@434977268&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;You can't able to add new Category to existing one, But you can Create a New Category Set and then Re-Insert the in the Binding Map.&lt;BR /&gt;&lt;BR /&gt;01. Create a New Category Set with Existing Categories.&lt;/P&gt;&lt;P&gt;02. Create a New Binding using New Category Set.&lt;/P&gt;&lt;P&gt;03. using&amp;nbsp;&lt;A title="Re-Insert" href="https://www.revitapidocs.com/2021.1/7b613771-310d-6d89-4b69-475a68033f73.htm" target="_blank" rel="noopener"&gt;https://www.revitapidocs.com/2021.1/7b613771-310d-6d89-4b69-475a68033f73.htm&lt;/A&gt;&amp;nbsp;Add the Category.&lt;BR /&gt;&lt;BR /&gt;Hope this Helps &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;</description>
      <pubDate>Thu, 15 Jun 2023 10:14:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/how-to-add-a-new-category-to-an-existing-project-parameter/m-p/12035794#M11414</guid>
      <dc:creator>Mohamed_Arshad</dc:creator>
      <dc:date>2023-06-15T10:14:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a new category to an existing project parameter</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-add-a-new-category-to-an-existing-project-parameter/m-p/12035896#M11415</link>
      <description>&lt;LI-CODE lang="general"&gt; string targetParamName = "Test";
                BuiltInCategory newCategory = BuiltInCategory.OST_Ceilings;

                DefinitionBindingMapIterator iter = document.ParameterBindings.ForwardIterator();
                BindingMap bdm = document.ParameterBindings;
                Category category = document.Settings.Categories.get_Item(newCategory);
                while (iter.MoveNext())
                {
                    Definition def = iter.Key;
                    if (def.Name == targetParamName)
                    {
                        ElementBinding binding = iter.Current as ElementBinding;
                        CategorySet categories = binding.Categories;
                        categories.Insert(category);
                        using (Transaction t = new Transaction(document, "Insert Category"))
                        {
                            t.Start();
                            CategorySet categorySet = new CategorySet();
                            foreach (Category item in categories)
                            {
                                categorySet.Insert(item);
                            }
                            InstanceBinding instanceBinding = document.Application.Create.NewInstanceBinding(categorySet);
                            bdm.ReInsert(def, instanceBinding);
                            t.Commit();
                        }
                        break;
                    }
                }&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;I changed the code according to what you said, but I found that it still doesn’t work. Can you help me see where the problem is? Thank you&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2023 10:50:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/how-to-add-a-new-category-to-an-existing-project-parameter/m-p/12035896#M11415</guid>
      <dc:creator>434977268</dc:creator>
      <dc:date>2023-06-15T10:50:22Z</dc:date>
    </item>
  </channel>
</rss>

