Revit Secondary Development Attach Filter to Linked Model in Project
View filters are divided into rule filters and selection filters:
Selection filter: Need to pass in elementId list to operate on specified Element
Rule filter: Through rule description of specified parameters, pass in categories Id for operation
Specifics can refer to API
—update—
2019 API deleted SET* command and model color specification method. Color attachment not tested, need to verify by yourself
1 | #if Revit2016 |
In general projects, if adding filter only need to use SelectionFilterElement command can add successfully. When we operate on linked model, because the extracted List
The following example is a case where custom value in linked model is >=Value&&<Value
if (!maxValue.Equals(minValue))
{
filterRules.Add(
ParameterFilterRuleFactory.CreateGreaterOrEqualRule(id, minValue, false));
filterRules.Add(ParameterFilterRuleFactory.CreateLessRule(id, maxValue, false));
}
else
{
filterRules.Add(
ParameterFilterRuleFactory.CreateEqualsRule(id, maxValue, false));
}
ParameterFilterElement filterElement = ParameterFilterElement.Create(document, name, categeorys);
filterElement.SetRules(filterRules);
view.AddFilter(filterElement.Id);
document.Regenerate();
OverrideGraphicSettings overrideSettings = view.GetFilterOverrides(filterElement.Id);
overrideSettings.SetProjectionFillColor(GetDBColorFromMediaColor(dictionary.Values.ElementAt(i)));
overrideSettings.SetProjectionFillPatternId(PatternId(document));
view.SetFilterOverrides(filterElement.Id, overrideSettings);
view.SetFilterVisibility(filterElement.Id, true);
filterRules.Clear();
In this way we can perform attach filter operation on linked model.
Reprint please indicate address: https://mp.csdn.net/mdeditor/89888384#




