We talked about redefining Project Parameter before. Now let’s see how ProjectParameter Reshaper of RevitAddinWizard can assist us to do the same work. The ProjectParameter Reshaper can be found from either the Revit Addin Coder sub-menu under the Tools or from Revit Addin Coder toolbar.
When the menu item or button is clicked, the ProjectParameter Reshaper window will show up:
If the OK button is clicked, the following ProjectParameter Reshaper will be created and added into the chosen class:
public static void RawReplaceProjectParameterWithExistingSharedParameter(RvtApplication app, string name, CategorySet cats, BuiltInParameterGroup group, bool inst)
{
DefinitionFile defFile = app.OpenSharedParameterFile();
if (defFile == null) throw new Exception("No SharedParameter File!");
var v = (from DefinitionGroup dg in defFile.Groups
from ExternalDefinition d in dg.Definitions
where d.Name == name
select d);
if (v == null || v.Count() < 1) throw new Exception("Invalid Name Input!");
ExternalDefinition def = v.First();
Autodesk.Revit.DB.Binding binding = app.Create.NewTypeBinding(cats);
if (inst) binding = app.Create.NewInstanceBinding(cats);
BindingMap map = (new UIApplication(app)).ActiveUIDocument.Document.ParameterBindings;
map.ReInsert(def, binding, group);
}
In terms of how to use these methods, please refer to previous posts for ideas and code examples.
ProjectParameter Reshaper of RevitAddinWizard can create all these in a second.
Recent Comments