Using a mask to filter list in Python

Hi everyone,

I am trying to use Python to get a list of views, then filter that list down to views where the ViewType == FloorPlan.
I’ve got the list of views, and I’ve got a list of booleans. How do I use the mask to filter down the list of views?

This is what I have at the moment. If is returning all the views but it is showing me which views are FloorPlan views. How do I remove the other views from the list?
Any help would be appreciated, thank you!

Hi @mitchellpUDG9S!

Can you replace

x = v.ViewType == ViewType.FloorPlan


If v.ViewType == ViewType.FloorPlan:


If v.ViewType == v.ViewType.FloorPlan:

Hi @dylim !

Thanks for the response.
I couldn’t replace that first line as that would leave the “x” variable as undefined. So I did the following:

So it worked in a way,. but it looks like it is returning the same floor plan multiple times… Any idea what I am doing wrong?

i just changed




Please check the new code in my first reply.

x will always return 0 or 1 cus the result of “==” is Boolean.
So if you do like views[x].
It shows 0 index or 1 index of views.

1 Like

Thanks very much dylim!

Worked like a charm, appreciate your help.

1 Like