Message 1 of 13
SetGroupTypeId for project parameters is not kept after closing the model
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have created a macro which changes the group for some project parameters. The macro works and I see the prameters under the new groups. I save and close the model and when I open it again the parameters are under the original groups.
public void ModifyParameterGroup()
{
Document doc = this.ActiveUIDocument.Document;
Autodesk.Revit.ApplicationServices.Application application = doc.Application;
Dictionary<string, ForgeTypeId> paramDict = new Dictionary<string, ForgeTypeId>();
//other
paramDict.Add("R_TEST", GroupTypeId.Phasing);
paramDict.Add("R_UniqueCatID", GroupTypeId.Phasing);
BindingMap bindingsMap = doc.ParameterBindings;
DefinitionBindingMapIterator iterator = bindingsMap.ForwardIterator();
using (Transaction t = new Transaction(doc, "Change Parameter Group"))
{
t.Start();
while (iterator.MoveNext())
{
ElementBinding elementBinding = iterator.Current as ElementBinding;
Definition definition = iterator.Key;
InternalDefinition intDef = definition as InternalDefinition;
if (paramDict.ContainsKey(definition.Name))
intDef.SetGroupTypeId(paramDict[definition.Name]);
}
t.Commit();
}
}