Message 1 of 6
Create View filters for project parameter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
Occasionally we have to make view filters multiple view filters in a model based on a project parameter. I am trying to put together a macro that I can modify when needed to help me create these filters. However, I am struggling with being able to select any parameters that are not built in to create filters. How can I find the parameter Id when i only have the name?
Thank you in advance.
public void viewFilter() { Document doc = this.ActiveUIDocument.Document; srviewfilter(doc,"PU"); } public void srviewfilter(Document doc,string typeabbreviation) { Element firstmech = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_MechanicalEquipment).FirstElement(); string prefix="Mech_Eq-"; IList<ElementId> catIds = new List<ElementId>(); catIds.Add(doc.Settings.Categories.get_Item("Mechanical Equipment").Id); catIds.Add(doc.Settings.Categories.get_Item("Duct Accessories").Id); string filtername=string.Concat(prefix,typeabbreviation); IList<FilterRule> rules = new List<FilterRule>(); ElementId paramID = new ElementId(firstmech.LookupParameter("TAG_MECH").Id); rules.Add(ParameterFilterRuleFactory.CreateEqualsRule(paramID,typeabbreviation, true)); using (Transaction t = new Transaction(doc,"View Filter")) { t.Start(); ParameterFilterElement filter = ParameterFilterElement.Create(doc, filtername, catIds, rules); t.Commit(); } }