Each Element carries many Parameter instances in Revit. Many times, it is necessary to filter them based on some criteria such as BuiltInParameterGroup, DisplayUnitType and StorageType. We will see how to do so with the assistance of the Parameter Filter of RevitAddinWizard.
It can be found from either the Revit Addin Coder sub-menu under the Tools menu or the following Revit Addin Coder toolbar:
When the button is clicked, the Parameter Filter window will show up:
If we’d like to filter Wall parameters by the BuiltInParameterGroup PG_CONSTRAINTS, DisplayUnitType DUT_FEET_FRACTIONAL_INCHES, StorageType as Double, and ReadOnly, we can fill in the window like the above. We can leave any drop down boxes empty if we don’t want to use them as filter criteria. After the filter name is given and a class in the current project is chosen, the following code will be created into the class as help methods which are ready to use anywhere anytime.
public static List<Parameter> ParametersOfWallConstraintsInchesDoubleReadOnly(Wall e)
{
return ParameterFilter_WallGroupUnitStorageReadOnly(e, BuiltInParameterGroup.PG_CONSTRAINTS, DisplayUnitType.DUT_FEET_FRACTIONAL_INCHES, StorageType.Double, true);
}
public static List<Parameter> ParameterFilter_WallGroupUnitStorageReadOnly(Wall e, BuiltInParameterGroup pg, DisplayUnitType ut, StorageType st, bool readOnly)
{
List<Parameter> paramList =
(from Parameter p in e.Parameters
where p.Definition.ParameterGroup == pg
&& p.DisplayUnitType == ut
&& p.StorageType == st
&& p.IsReadOnly == readOnly
select p).ToList();
return paramList;
}
If a wall selection method is also created using Object Picker of RevitAddinWizard:
public static Reference SelectWall(Selection selection)
{
Reference picked = selection.PickObject(ObjectType.Element, new RevitAddinCS.SelectionFilter1(), "Please select a wall");
return picked;
}
the following code can be used to exercise all the generated help methods:
Element element = SelectWall(cmdData.Application.ActiveUIDocument.Selection).Element;
List<Parameter> paramList = ParametersOfWallConstraintsInchesDoubleReadOnly(element as Wall);
MessageBox.Show("Parameter count: " + paramList.Count);
Parameter Filter of RevitAddinWizard can help do these and more automatically in no time.
Links to some related articles:Parameter of Revit API - BuiltInParameter
Parameter Retriever of RevitAddCoder
Parameter of Revit API - Parameter Information
Parameter Infoer of RevitAddCoder
Parameter of Revit API - ParameterType And StorageType
Parameter Typer of RevitAddCoder
Parameter of Revit API - BuiltInParameterGroup
Parameter Grouper of RevitAddCoder
Parameter of Revit API - Read/Write Parameter Values
Recent Comments