Message 1 of 6
Analytical model filtering for FilteredElementsCollector?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
UIApplication uiApp = commandData.Application; Document doc = uiApp.ActiveUIDocument.Document; FilterIntegerRule rule = new FilterIntegerRule(new ParameterValueProvider(new ElementId(BuiltInParameter.STRUCTURAL_ANALYTICAL_MODEL)), new FilterNumericEquals(), 1); ElementParameterFilter filter = new ElementParameterFilter(rule); FilteredElementCollector filterCol = new FilteredElementCollector(doc); filterCol.Where(e => e.CanHaveAnalyticalModel()); //This absolutely did nothing???! filterCol.WhereElementIsNotElementType(); filterCol.WherePasses(filter); var eleList = (List<Element>)filterCol.ToElements(); if(eleList.Count==0) { TaskDialog.Show("Hint", "There are no enabled AnalyticalModels"); } foreach (Element e in eleList) { using (Transaction trans = new Transaction(doc)) { trans.Start("Disabling Analytical Model"); bool success= e.get_Parameter(BuiltInParameter.STRUCTURAL_ANALYTICAL_MODEL).Set(0); trans.Commit(); } }
I have noticed that this code can filter elements based on which have enabled analytical model to disable them, however if I used the linq where extended function to query for any element that can have analytical models, without filtering for this custom rule made in the above code, it just gives back many irrelevant elements? I wonder why did this happen?