The API is a little confusing here. There are ElementFilter's which can be used to query the Revit document for specific Element's, and there are FilterElement's which can be used to create a filter for a View within the document.
Querying the Document
If you are attempting to query the model for elements given their parameter value you can do this using either get_Parameter() or LookUpParameter() methods for that element. get_Parameter() will work for built-in parameters or shared parameters where you know the GUID. You should be able to get the GUID of your SharedParameter either by looking at the SharedParameter file or using the Revit LoookUp tool. If you only know the name of the parameter, you can user LookupParameter(), but do know that this method is a little slower.
For example, if you are trying to get all walls with a height greater than 5', you could do the following:
var fec = new FilteredElementCollector(doc)
.OfClass(typeof(Wall))
// Replace BuiltInParameter with your SharedParameter's GUID
.Where(x => x.get_Parameter(BuiltInParameter.WALL_USER_HEIGHT_PARAM)?.AsDouble() > 5)
.ToList();
If you only know the name of the paramter, you could do the following:
var fec = new FilteredElementCollector(doc)
.OfClass(typeof(Wall))
.Where(x => x.LookupParameter("Unconnected Height")?.AsDouble() > 5)
.ToList();
Applying a filter to a view
If you are looking to apply a filter to a view, then you will need to use a FilterElement and apply that to a view. For example, the following will hide all of the walls with the text "some value" in MySharedParam in the current view:
using (var t = new Transaction(doc, "Add filter"))
{
t.Start();
var parameter = new FilteredElementCollector(doc)
.OfClass(typeof(SharedParameterElement))
.OfType<SharedParameterElement>()
.Where(x => x.GuidValue == new Guid("cf973001-e6e2-4e80-b502-ff74918165c9")) // if you know the GUID
.Where(x => x.Name == "MySharedParam") // if you know the name
.FirstOrDefault();
var filterRule = ParameterFilterRuleFactory.CreateContainsRule(parameter.Id, "some value", false);
var parameterFilter = new ElementParameterFilter(filterRule);
var categories = new List<ElementId> { new ElementId(BuiltInCategory.OST_Walls) };
var filterElement = ParameterFilterElement.Create(doc, "Filter", categories, parameterFilter);
view.SetFilterVisibility(filterElement.Id, false);
t.Commit();
}
ElementFilter. However, your link is for aFilterElement, which is to create a filter for a given view in the UI, which would only show elements in that view that pass the filter. If you see the comment at the bottom of that article, this is an easy confusion revitapidocs.com/2015/…