Dear All,
is there a way to update existing ProjectParameter (e.g add new category to categorySet) differently than using ReInsert method from BindingMap? The problem with this one is that it removes existing ProjectParam and later creates new with new CategorySet, therefore already-specified and stored in this Parameter values would be gone!
ReInsert method:
https://www.revitapidocs.com/2023/7b613771-310d-6d89-4b69-475a68033f73.htm
any help much appreciated,
Lukasz
Solved! Go to Solution.
Solved by architect.bim. Go to Solution.
HI @lwlXUTTT
I already answered for the issue. Kindly Check the Below Link and Reference Code.
Script
//Global Variables
InstanceBinding instanceBinding = null;
Definition def = null;
//Category Need to Add to the Existing Prameter Bindings
Category cat = Category.GetCategory(doc, BuiltInCategory.OST_Assemblies);
//Get Instance Binding From Document
var map = doc.ParameterBindings.ForwardIterator();
//Iterate using Iterator
while (map.MoveNext())
{
//Get the Parameter need to add
def = map.Key as Definition;
if (def.Name == "Demo")
{
instanceBinding = map.Current as InstanceBinding;
}
}
//Get Existing Category Set From the Binding
CategorySet existingSet = instanceBinding.Categories;
if(!existingSet.Contains(cat))
{
existingSet.Insert(cat);
}
//Adding Category to Exsting Instance Binding (Without changing any parameter)
using (Transaction addCategory = new Transaction(doc,"Add Category"))
{
addCategory.Start();
//Re-Insert Categories to Exsting Instance Binding
instanceBinding.Categories = existingSet;
doc.ParameterBindings.ReInsert(def, instanceBinding);
addCategory.Commit();
}
Hope this Helps 🙂
HI @architect.bim
I have solved this issue. Without losing value I can be able to re-insert new Category for Existing Parameters Bindings. Can you please suggest any idea on this 🙂
workaround with saved values to Cache solved the issue partially, I will mark it as a solution -> problem exists for example, when project parameters are used in KeySchedules -> after reinserting, they are gone from key schedule
Can't find what you're looking for? Ask the community or share your knowledge.