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.
Solved by jeremytammik. Go to Solution.
Dear Auke,
Thank you for your query.
I assume you have already studied the Revit SDK sample ElementFilter/ViewFilters?
Does it not illustrate this aspect of setting up a filter?
Best regards,
Jeremy
I did but i find it sometimes difficult to understand the SDK samples.
But I took a look again and got the SKD sample working so i also could use debug to see what is does. And found some things i overlooked.
Thank you, i have it working now. It was a stupid thing i overlooked in the buildin Parameters, but sometimes it happens.
ps. I think i did something wrong with creating the original post. Just do not know what.
Congratulations on solving it! I am glad the suggestion helped. I did not notice anything wrong with your post...
Best regards,
Jeremy
Can't find what you're looking for? Ask the community or share your knowledge.