- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All,
I’m working on a program that cleans up “orphaned” shared parameters that get introduced into a model from third-party families.
I’ve got the whole thing working (just barely….not a lot of guardrails yet), but I’m having problems with the ReplaceParameter method. It doesn't behave as nicely as the Revit interface where all you have to do is just select the family parameter radio button (see screen shot). Instead, it throws an exception if you replace the old shared parameter with a new family parameter that uses the same name. I’ve taken a few stabs at changing the name before and after using ReplaceParameter but have failed both ways.
Does anyone know if there is a way rename the parameter after or before the replacement? You will see some REMed lines in my attached code that show one attempt to change the parameter name to “temp” prior to replacing.
using (Transaction tx = new Transaction(famDoc, "editing parameter in: " + f.Name))
{
tx.Start();
//oldName = p.Definition.Name;
//famDoc.FamilyManager.RenameParameter(p, "temp");
newParam =famDoc.FamilyManager.ReplaceParameter(p, p.Definition.Name + "1", p.Definition.ParameterGroup, p.IsInstance);
//famDoc.FamilyManager.RenameParameter(newParam, oldName);
tx.Commit();
}
Regards,
James
Solved! Go to Solution.