Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

view filter by elementIds

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
office
1129 Views, 6 Replies

view filter by elementIds

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?

 

6 REPLIES 6
Message 2 of 7
jeremytammik
in reply to: office

Dear Koppevi,

 

Please take a look at the Revit SDK ElementFilter / ViewFilters sample and let us know whether that helps.

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 7
office
in reply to: office

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

 

 

Message 4 of 7
office
in reply to: office

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)

 

Message 5 of 7
office
in reply to: office

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

 
 

 

Message 6 of 7
office
in reply to: office

sorry, obviously got late teh other night... solved

Message 7 of 7
jeremytammik
in reply to: office

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!



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community