ParameterBindings.ReInsert returns false for existing Project Parameters when adding Categories

ParameterBindings.ReInsert returns false for existing Project Parameters when adding Categories

gopinath.rajendran
Advocate Advocate
272 Views
0 Replies
Message 1 of 1

ParameterBindings.ReInsert returns false for existing Project Parameters when adding Categories

gopinath.rajendran
Advocate
Advocate

Revit 2024.3.4
I am encountering an issue with ParameterBindings.ReInsert when attempting to add a category to an existing Project Parameter created via the Revit UI (non-shared).

This does not involve shared parameters. The parameter is a standard project parameter visible in the Project Parameters dialog and already bound to one or more categories.

The goal is to add an additional category to the existing project parameter without deleting and recreating it.

I retrieve the Definition and ElementBinding directly from Document.ParameterBindings using BindingMap.ForwardIterator. The definition passed to ReInsert is exactly the same Definition obtained from the binding map.

Inside a valid transaction, I construct a new CategorySet, create a new InstanceBinding or TypeBinding matching the existing binding type, and call ReInsert.

Minimal snippet illustrating the failing call:

BindingMap map = doc.ParameterBindings;

Category cat = Category.GetCategory(doc, categoryToAdd);

CategorySet newSet = doc.Application.Create.NewCategorySet();
foreach (Category c in existingBinding.Categories)
  newSet.Insert(c);
newSet.Insert(cat);

ElementBinding newBinding =
  existingBinding is InstanceBinding
    ? doc.Application.Create.NewInstanceBinding(newSet)
    : doc.Application.Create.NewTypeBinding(newSet);

bool result = map.ReInsert(definitionFromMap, newBinding); // result == false for existing Project Parameters

 

Observed behavior:

  • ReInsert returns false for existing UI-created project parameters

  • No exception is thrown

  • The category is valid and available in the document

  • The category is not already present in the binding

  • The definition and binding are obtained directly from ParameterBindings

I have also tried:

  • Modifying the existing binding’s CategorySet in place and calling ReInsert

  • Replacing the CategorySet on the existing binding before calling ReInsert

All approaches show the same behavior for the affected project parameters.

Questions:

  1. Are there known limitations where ParameterBindings.ReInsert cannot modify category bindings for UI-created project parameters?

  2. Are project parameters effectively immutable with respect to category changes after creation?

A full reproducible sample is attached.

273 Views
0 Replies
Replies (0)