<?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 Betreff: Binding Shared Parameters Failing on some Categories in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/binding-shared-parameters-failing-on-some-categories/m-p/11877929#M26577</link>
    <description>&lt;P&gt;I have the very same problem. I cannot add some parameters to some categories by script. When I do it manually it works fine. I´m using Revit 2021. Did anyone solve this problem?&lt;BR /&gt;&lt;BR /&gt;I tried to get the categories with:&lt;/P&gt;&lt;P&gt;Category cat = doc.Settings.Categories.get_Item(builtInCategory);&lt;/P&gt;&lt;P&gt;and&amp;nbsp;&lt;BR /&gt;Category cat = Category.GetCategory(doc, builtInCategory);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It does not work when adding these to my CategorySet.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Binding the parameter to the category Ebenen is not allowed&lt;/P&gt;</description>
    <pubDate>Thu, 06 Apr 2023 15:25:23 GMT</pubDate>
    <dc:creator>bixilix</dc:creator>
    <dc:date>2023-04-06T15:25:23Z</dc:date>
    <item>
      <title>Binding Shared Parameters Failing on some Categories</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/binding-shared-parameters-failing-on-some-categories/m-p/10239604#M26573</link>
      <description>&lt;P&gt;In the Revit API, I have created the Shared Parameters file and in the routine applied it to the project and in doing create a group definition fine. I am getting the definition file within the api, and am successful at getting the category cat returned. (Jeremy has a previous routine I basically used, but modified it further to solve some holes - can post more), next I loop through the public array called:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;public static BuiltInCategory[] AnalyticsDataTargets = new BuiltInCategory[] {&lt;BR /&gt;BuiltInCategory.OST_DuctCurves, BuiltInCategory.OST_DuctFitting, BuiltInCategory.OST_DuctAccessory, BuiltInCategory.OST_FlexDuctCurves, BuiltInCategory.OST_DuctTerminal,&lt;BR /&gt;BuiltInCategory.OST_MechanicalEquipment,&lt;BR /&gt;BuiltInCategory.OST_PipeCurves, BuiltInCategory.OST_PipeFitting, BuiltInCategory.OST_PipeAccessory, BuiltInCategory.OST_PlumbingFixtures,&lt;BR /&gt;BuiltInCategory.OST_Conduit, BuiltInCategory.OST_ConduitFitting,&lt;BR /&gt;BuiltInCategory.OST_CableTray, BuiltInCategory.OST_CableTrayFitting,&lt;BR /&gt;BuiltInCategory.OST_ElectricalEquipment, BuiltInCategory.OST_ElectricalFixtures, BuiltInCategory.OST_LightingDevices, BuiltInCategory.OST_LightingFixtures };&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;public static void AssignSharedInstanceParameterToCategories(Document doc, string defname, string AnalyticsMEPSharedParameterGroupName)&lt;BR /&gt;{&lt;BR /&gt;Application app = doc.Application;&lt;BR /&gt;bool BindingCreatedSucceeded = false;&lt;BR /&gt;bool typeParameter = false;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/// This needs to be a repeatable function passing DefinitionName and DefinitionType&lt;BR /&gt;using (Transaction t = new Transaction(doc))&lt;BR /&gt;{&lt;BR /&gt;t.Start("Create Shared Parameter");&lt;BR /&gt;Category cat;&lt;/P&gt;&lt;P&gt;// create instance parameters:&lt;BR /&gt;foreach (BuiltInCategory target in AnalyticsDataTargets)&lt;BR /&gt;{&lt;BR /&gt;cat = GetCategory(doc, target);&lt;BR /&gt;if (null != cat)&lt;BR /&gt;{&lt;BR /&gt;CreateSharedParameterBindingToCategorySet(doc, cat, defname, typeParameter, AnalyticsMEPSharedParameterGroupName);&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;t.Commit();&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And within that CreateSharedParameterBindingToCategorySet used Jeremy's example (I can post my efforts at the SDK example approach as well). It isnt working for all categories - not sure why and could use help:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;static bool CreateSharedParameterBindingToCategorySet(Document doc, Category cat, string defname, bool typeParameter, string AnalyticsMEPSharedParameterGroupName)&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;Application app = doc.Application;&lt;BR /&gt;Autodesk.Revit.Creation.Application ca = app.Create;&lt;BR /&gt;string filename = app.SharedParametersFilename;&lt;BR /&gt;DefinitionFile file = app.OpenSharedParameterFile();&lt;/P&gt;&lt;P&gt;DefinitionGroup group = file.Groups.get_Item(AnalyticsMEPSharedParameterGroupName);&lt;BR /&gt;bool visible = cat.AllowsBoundParameters;&lt;BR /&gt;Definition definition = group.Definitions.get_Item(defname);&lt;/P&gt;&lt;P&gt;// create the category set containing our category for binding:&lt;BR /&gt;CategorySet catSet = ca.NewCategorySet();&lt;BR /&gt;catSet.Insert(cat);&lt;BR /&gt;try&lt;BR /&gt;{&lt;BR /&gt;Binding binding;&lt;/P&gt;&lt;P&gt;if (typeParameter == true)&lt;BR /&gt;{&lt;BR /&gt;// Binding binding = typeParameter&lt;BR /&gt;// ? ca.NewTypeBinding(catSet) as Binding&lt;BR /&gt;// : ca.NewInstanceBinding(catSet) as Binding;&lt;BR /&gt;binding = ca.NewTypeBinding(catSet) as Binding;&lt;BR /&gt;}&lt;BR /&gt;else&lt;BR /&gt;{&lt;BR /&gt;binding = ca.NewInstanceBinding(catSet) as Binding;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;// we could check if it is already bound, but it looks like insert will just ignore it in that case:&lt;BR /&gt;// NEED THE CODE FOR THIS CHECK - THAT IS THE POINT FOR DEBUG&lt;BR /&gt;&lt;BR /&gt;// Option to not Specify the Parameter Group&lt;BR /&gt;doc.ParameterBindings.Insert(definition, binding);&lt;/P&gt;&lt;P&gt;// Option to specify the parameter group here:&lt;BR /&gt;// doc.ParameterBindings.Insert(definition, binding, BuiltInParameterGroup.PG_GENERAL);&lt;/P&gt;&lt;P&gt;string strTypeParam = "";&lt;BR /&gt;if (typeParameter)&lt;BR /&gt;{&lt;BR /&gt;strTypeParam = "type";&lt;BR /&gt;}&lt;BR /&gt;else&lt;BR /&gt;{&lt;BR /&gt;strTypeParam = "instance";&lt;BR /&gt;}&lt;BR /&gt;string DebugTest = "Created a shared {0} parameter '{1}' for the {2} category. " + strTypeParam + "defname = " + defname + "catName = " + cat.Name;&lt;/P&gt;&lt;P&gt;}&lt;BR /&gt;catch (Exception ex)&lt;BR /&gt;{&lt;BR /&gt;//Util.ErrorMsg(string.Format( "Error binding shared parameter to category {0}: {1}", cat.Name, ex.Message));&lt;BR /&gt;return false;&lt;BR /&gt;}&lt;BR /&gt;return true;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;</description>
      <pubDate>Thu, 15 Apr 2021 03:38:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/binding-shared-parameters-failing-on-some-categories/m-p/10239604#M26573</guid>
      <dc:creator>greg7KTAR</dc:creator>
      <dc:date>2021-04-15T03:38:49Z</dc:date>
    </item>
    <item>
      <title>Binding Shared Parameters Failing on some Categories</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/binding-shared-parameters-failing-on-some-categories/m-p/10239879#M26574</link>
      <description>&lt;P&gt;For some categories, this is a known issue. Maybe you are running into the same.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I cannot view your attached image. It says:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;gt; Document preview of Support Shared Parameters Binding to Element Categories.png&lt;BR /&gt;&amp;gt; Error displaying attachment content&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you share a complete minimal reproducible case that I can pass on to the development team in case there is a problem that needs reporting?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://thebuildingcoder.typepad.com/blog/about-the-author.html#1b" target="_blank"&gt;https://thebuildingcoder.typepad.com/blog/about-the-author.html#1b&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Apr 2021 06:07:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/binding-shared-parameters-failing-on-some-categories/m-p/10239879#M26574</guid>
      <dc:creator>jeremy_tammik</dc:creator>
      <dc:date>2021-04-15T06:07:37Z</dc:date>
    </item>
    <item>
      <title>Re: Binding Shared Parameters Failing on some Categories</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/binding-shared-parameters-failing-on-some-categories/m-p/10242360#M26575</link>
      <description>&lt;P&gt;Jeremy:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your reply. I would like to produce a cast, however, this morning I found a solution that looks like it works (with some caveats), and with that in mind I can no longer reproduce exactly the same thing. However, I may be able to pinpoint the problem with a screen cast after I clean up this set of code. Here's an update as to my experience. It appears if you set the categories once, you can't re-set them to a project or set them to more categories later(at least with the code I am using)&amp;nbsp; - and therein could be the root of the issue.&amp;nbsp; So starting fresh, if I set them all at once (in a small test it worked). I may need help to set the variables themselves later - or deal with partially set models needing the remaining categories or Shared Parameters added, but am getting the fields on all items when i do it this way. I switched to the method from the SDK, which does all the CatSet.Insert on all categories at once, such as:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Category DuctClassification = doc.Settings.Categories.get_Item(BuiltInCategory.OST_DuctCurves);&lt;BR /&gt;Category DuctFittingsClassification = doc.Settings.Categories.get_Item(BuiltInCategory.OST_DuctFitting);&lt;BR /&gt;Category DuctAccessoryClassification = doc.Settings.Categories.get_Item(BuiltInCategory.OST_DuctAccessory);&lt;BR /&gt;Category FlexDuctClassification = doc.Settings.Categories.get_Item(BuiltInCategory.OST_FlexDuctCurves);&lt;/P&gt;&lt;P&gt;catSet.Insert(DuctClassification);&lt;BR /&gt;catSet.Insert(DuctFittingsClassification);&lt;BR /&gt;catSet.Insert(DuctAccessoryClassification);&lt;BR /&gt;catSet.Insert(FlexDuctClassification);&lt;/P&gt;</description>
      <pubDate>Thu, 15 Apr 2021 20:44:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/binding-shared-parameters-failing-on-some-categories/m-p/10242360#M26575</guid>
      <dc:creator>greg7KTAR</dc:creator>
      <dc:date>2021-04-15T20:44:29Z</dc:date>
    </item>
    <item>
      <title>Re: Binding Shared Parameters Failing on some Categories</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/binding-shared-parameters-failing-on-some-categories/m-p/10242371#M26576</link>
      <description>&lt;P&gt;Have you tried to bind one of those parameters manually to the families to see what if anything it says? In the past, i have ran into what Jeremy is describing with certain parameter types not being supported by some categories.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Apr 2021 20:50:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/binding-shared-parameters-failing-on-some-categories/m-p/10242371#M26576</guid>
      <dc:creator>Sean_Page</dc:creator>
      <dc:date>2021-04-15T20:50:22Z</dc:date>
    </item>
    <item>
      <title>Betreff: Binding Shared Parameters Failing on some Categories</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/binding-shared-parameters-failing-on-some-categories/m-p/11877929#M26577</link>
      <description>&lt;P&gt;I have the very same problem. I cannot add some parameters to some categories by script. When I do it manually it works fine. I´m using Revit 2021. Did anyone solve this problem?&lt;BR /&gt;&lt;BR /&gt;I tried to get the categories with:&lt;/P&gt;&lt;P&gt;Category cat = doc.Settings.Categories.get_Item(builtInCategory);&lt;/P&gt;&lt;P&gt;and&amp;nbsp;&lt;BR /&gt;Category cat = Category.GetCategory(doc, builtInCategory);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It does not work when adding these to my CategorySet.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Binding the parameter to the category Ebenen is not allowed&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2023 15:25:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/binding-shared-parameters-failing-on-some-categories/m-p/11877929#M26577</guid>
      <dc:creator>bixilix</dc:creator>
      <dc:date>2023-04-06T15:25:23Z</dc:date>
    </item>
  </channel>
</rss>

