is there a way to create a view filter from a given list of element(Ids)?
why that: my calculation leaves me with a subset of elements i want to have visible in a view.
i fail to construct a view filter for this list.
any suggestions?
Solved! Go to Solution.
Solved by jeremytammik. Go to Solution.
Dear Koppevi,
Please take a look at the Revit SDK ElementFilter / ViewFilters sample and let us know whether that helps.
Cheers,
Jeremy
def CreateFilter(elements,view): filtertmp=[] filtertmp.append(ElementId(BuiltInCategory.OST_GenericModel)) filtertmp.append(ElementId(BuiltInCategory.OST_CurtainWallPanels)) filtertmp.append(ElementId(BuiltInCategory.OST_Rebar)) categories = List[ElementId](filtertmp) parameter=elements[0].get_Parameter("Mark") checkval =parameter.AsString() parameterId = parameter.Id pvp = ParameterValueProvider(parameterId) TransactionManager.Instance.EnsureInTransaction(doc) fnrv = FilterStringEquals() rulelist = [] ruleValId = checkval paramFr = FilterStringRule(pvp,fnrv,ruleValId,True) epf = ElementParameterFilter(paramFr) rulelist.append(paramFr) collector = FilteredElementCollector(doc,doc.ActiveView.Id) collector.OfCategory(BuiltInCategory.OST_GenericModel).WherePasses(epf) collector.OfCategory(BuiltInCategory.OST_CurtainWallPanels).WherePasses(epf) collector.OfCategory(BuiltInCategory.OST_Rebar).WherePasses(epf) filterRules=List[FilterRule](rulelist) elemFilter = ParameterFilterElement.Create(doc,"FLT" + view.Name,categories,filterRules) view.AddFilter(elemFilter.Id) view.SetFilterVisibility(elemFilter.Id,True) TransactionManager.Instance.TransactionTaskDone() return()
jeremy, thank you for the quick reply!
1st: yes i examined the samples, and as you see my code is more or less a mimicry .
what i tried:
i have codes stored in the "Mark" parameter.i wanted to create views where only elements matching the criteria are displayed and those elements should only be panels, generic models and rebar. (so everything else should be off)
trying the code (adding a red color for debuging) i think it worked.
but when i tried to generate my drawings i failed.
examining the drawings i can see, that my filter is applied
i examined the result in my drawings.
1) the filter is applied to the view.
2) the filter says in Visibility/Graphics exactly what i expected. filter parameter "Mark" equals "1"
3) the result i see is elements not equaling "1" ( this i examined with a view filter listing all elements in view)
now i found your post from jan this year. tried to implement it, but!
def GetApp(bip): catlist = [] allCategories = ParameterFilterUtilities.GetAllFilterableCategories() for categoryId in allCategories: applicableParameters = ParameterFilterUtilities.GetFilterableParametersInCommon(doc, List[ElementId](categoryId)) if bip in applicableParameters: catlist.append(categoryId) retResult=List[ElementId](catlist) return (retResult)
whatever i try calling .GetFilterableParametersInCommon() gives me a type error.
"expected int, got ElementId"
i am clueless as the api manual (and your post) tell me that an ICollection of type ElementId is correct?????????
thnaks in advance
Please mark the solution using the 'Accept as Solution' button.
That makes it easier for others to see and understand and helps keep track of the unsolved cases.
Thank you!