Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All,
I am trying to filter rebar and apply a colour to it depending on it's size. I have noticed that ParameterFilterElement is removed from 2020.
I have having some issues with creating the filter.
public void CreateFilter(Document doc, View view, double barDiameter)
{
// create list of categories that will for the filter
IList<ElementId> categories = new List<ElementId>();
categories.Add(new ElementId(BuiltInCategory.OST_Rebar));
// create a list of rules for the filter
IList<FilterRule> rules = new List<FilterRule>();
// This filter will have a single rule for the filter
Parameter rebarSize = new FilteredElementCollector(doc).OfClass(typeof(Rebar)).FirstElement().get_Parameter(BuiltInParameter.REBAR_BAR_DIAMETER);
rules.Add(ParameterFilterRuleFactory.CreateLessRule(rebarSize.Id, barDiameter, 0.1));
ParameterFilterElement filter = null;
using (Transaction t = new Transaction(doc, "Create and Apply Filter"))
{
t.Start();
filter = ParameterFilterElement.Create(doc, "Thin Wall Filter", categories,rules);
view.AddFilter(filter.Id);
t.Commit();
}
string filterNames = "";
foreach (ElementId id in view.GetFilters())
{
filterNames += doc.GetElement(id).Name + "\n";
}
OverrideGraphicSettings ogs = new OverrideGraphicSettings();
ogs.SetCutLineColor(new Color((byte)255, (byte)0, (byte)0));
//ogs.SetCutLineColor(getColour(doc.Application,12));
using (Transaction t = new Transaction(doc, "Set Override Appearance"))
{
t.Start();
view.SetFilterOverrides(filter.Id, ogs);
t.Commit();
}
}
I think I have the rest of it correct, but can't test unitl I fix the ParameterFilterElement issue.
Can anyone point me in the right direction on how to do this?
Thanks,
Brent
Solved! Go to Solution.