Python - filter elements by parameters

Sorry for the novice question but I am trying to understand how you use Python to collect to elements and then filter one against the other.

set a = [1, 2, 3, 4]

set b = [3, 4, 5, 6, 7]

returns [5, 6, 7]

 

Here is what I have for collecting the two items that I want to filter. Thanks again for any help. Sorry for the remedial question.

#collect all area plan views

collector = FilteredElementCollector(doc)

views = collector.OfClass(view).ToElements()

areaPlans = []

 

 

#collect all view filters in model

collector = FilteredElementCollector(doc)

filters = collector.OfClass(ParameterFilterElement).ToElements()

 

 

Hi,

quick copy paste from: http://stackoverflow.com/questions/3462143/get-difference-between-two-lists :slight_smile:

Thanks Tomasz. I’ll give it a go.

Really what I am trying to get python to do is to return only the (ParameterFilterElements) from specific view types, in this case the area plans that are in my model. Any suggestions? Thanks again.

can you post this question to Stack Overflow and post a link to it here? I hate to post code in this blog because it’s impossible to format it properly. I will answer that question on Stack Overflow. Thanks!

Thanks for your reply. I have posted on Stackoverflow.

http://stackoverflow.com/questions/35492815/use-python-to-get-view-filters-for-views-in-revit-project

 

I’ll admit that I am fairly new to Dynamo and Python but I’m working through some examples and looking at some custom nodes to try to learn. Konrad do you have any other good sources on how to learn Python? Thanks for your patience and help.

Konrad, Thanks for the response. It has been really helpful to see examples from more experienced users. Thanks for taking a look at it.

Can you approve my answer if it is the correct answer. Thank you,

Your answer almost got me there. I was looking to get the View Filters that were not being used. I used another piece of python to get all of the View Filters in the document and then used ‘SetDifference’ node to get the unused filters. Thanks again for the help.

 

ViewFiltersKS

My, bad I must have misread the question. I thought you wanted to see what Filters were used in what Views. Anyways, I am glad I could help.