Keen readers may have noticed that in the previous post some code methods are not really in the BindingMap class. Sorry for that. They are some extensions to the BindingMap class.
Revit Parameter Organizer can organize various Revit parameters such as Shared Parameters, Family Parameters, Project Parameters and Built-in Parameter in many good ways.
Here they are, along with some more extension methods not used yet:
public static bool IsInstance(this Binding binding)
{
return (binding as InstanceBinding) != null;
}
public static CategorySet GetCategories(this Binding binding)
{
if (binding.IsInstance())
return (binding as InstanceBinding).Categories;
else
return (binding as TypeBinding).Categories;
}
public static Autodesk.Revit.DB.Definition GetDefiniton(this BindingMap map, string name)
{
DefinitionBindingMapIterator it = map.ForwardIterator();
it.Reset();
while (it.MoveNext())
{
if (it.Key.Name == name)
{
return it.Key;
}
}
return null;
}
public static Autodesk.Revit.DB.Binding GetBinding(this BindingMap map, string name)
{
DefinitionBindingMapIterator it = map.ForwardIterator();
it.Reset();
while (it.MoveNext())
{
if (it.Key.Name == name)
{
return it.Current as Autodesk.Revit.DB.Binding;
}
}
return null;
}
public static KeyValuePair<Autodesk.Revit.DB.Definition, Autodesk.Revit.DB.Binding> GetDefinitonBindingPair(this BindingMap map, string name)
{
DefinitionBindingMapIterator it = map.ForwardIterator();
it.Reset();
while (it.MoveNext())
{
if (it.Key.Name == name)
{
return new KeyValuePair<Definition, Binding>(it.Key, it.Current as Autodesk.Revit.DB.Binding);
}
}
return new KeyValuePair<Definition,Binding>(null, null);
}
public static void TruelyClear(this BindingMap map)
{
DefinitionBindingMapIterator it = map.ForwardIterator();
it.Reset();
while (it.MoveNext())
{
map.Remove(it.Key);
}
}
Just a kind reminder in case: please put these extension methods into a public static class and import its namespace into the source that you’d like to use them. Enjoy!
ProjectParameter Extensioner of Revit Addin Coder will create them automatically into where we want them to be in no time.
Recent Comments