Hello everyone, i have a problem i can not get my head around.
For some reason i can not get the code below to work (well it works but not how it supposed to) Eith the below code the filter is being made and applied to the view. But there is no category selected (see screenshot) how to i get it so the category elevation is selected in the filter. Hope someone can help me.
// create list of categories that will for the filter IList<ElementId> categories = new List<ElementId>(); categories.Add(new ElementId(BuiltInCategory.OST_Views)); //Works but for creating but no categories is selected. I need to select Elevation but categorie is empty now. // create a list of rules for the filter Parameter param = null; IList<FilterRule> rules = new List<FilterRule>(); foreach (View item in new FilteredElementCollector(curDoc).OfClass(typeof(View))) { if(item.ViewType == ViewType.Elevation) { param = item.get_Parameter(BuiltInParameter.VIEWPORT_SHEET_NUMBER); break; } } rules.Add(ParameterFilterRuleFactory.CreateNotContainsRule(param.Id, sheet.SheetNumber, false)); //apply filter to view ParameterFilterElement filter = null; using (Transaction t = new Transaction(curDoc, "Create and Apply Filter")) { t.Start(); filter = ParameterFilterElement.Create(curDoc, "_PBT_" + view.Name, categories, rules); view.AddFilter(filter.Id); //set filter overrides view.SetFilterVisibility(filter.Id, false); t.Commit(); }
How it looks when this code is executed:
How it should look in the filter:
Solved! Go to Solution.
Link copied