We talked about erasing Project Parameters before. Now let’s see how ProjectParameter Eraser of RevitAddinWizard can assist us to do the same work. The ProjectParameter Eraser 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 Eraser window will show up:
If the OK button is clicked, the following ProjectParameter Eraser code will be created and added into the chosen class:
public static bool RawEraseProjectParameter(RvtDocument doc, string name, ParameterType type)
{
BindingMap map = doc.ParameterBindings;
DefinitionBindingMapIterator it = map.ForwardIterator();
it.Reset();
Definition def = null;
while (it.MoveNext())
{
if (it.Key != null && it.Key.Name == name && type == it.Key.ParameterType)
{
def = it.Key;
break;
}
}
if (def != null)
{
map.Remove(def);
return true;
}
return false;
}
public static void RawTruelyEraseAllProjectParameters(RvtDocument doc)
{
BindingMap map = doc.ParameterBindings;
TruelyClear(map);
}
public static void TruelyClear(BindingMap map)
{
DefinitionBindingMapIterator it = map.ForwardIterator();
it.Reset();
while (it.MoveNext())
{
map.Remove(it.Key);
}
}
In terms of how to use these methods, please refer to previous posts for ideas and code examples.
ProjectParameter Eraser of RevitAddinWizard can create all these in a second.
Recent Comments