Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, I have a method that gives me all FamilyInstances that are hostet by the given element.
I was wondering if it is possible to achieve that by only using Revits Element filters, since my current implementation is slowing down my application.
public List<FamilyInstance> FamilyInstancesWithElementAsHost(Element element)
{
return new FilteredElementCollector(element.Document).OfClass(typeof(FamilyInstance))
.Cast<FamilyInstance>()
.Where(fi => fi.Host != null && fi.Host.Id.IntegerValue == element.Id.IntegerValue)
.ToList();
}
I tried it like this, but it looks this parameter is always set to "-1":
BuiltInParameter bip = BuiltInParameter.HOST_ID_PARAM;
FilterableValueProvider filterableValueProvider = new ParameterValueProvider(new ElementId(bip));
FilterNumericRuleEvaluator filterNumericRuleEvaluator = new FilterNumericEquals();
FilterRule filterRule = new FilterElementIdRule(filterableValueProvider, filterNumericRuleEvaluator, element.Id);
ElementFilter elementFilter = new ElementParameterFilter(filterRule);
var betterVersion = new FilteredElementCollector(element.Document)
.OfClass(typeof(FamilyInstance))
.WherePasses(elementFilter)
.ToList();
Solved! Go to Solution.