Find elements with same material?

Can I find all elements that have the same material? Specifically is there a way to find ALL the elements on the 1st floor that have the material class of Concrete?
I’ve found all the materials that have the material class of concrete. I’ve found all the elements on level 1. But I cannot understand why I can’t filter the elements at level 1 by elements with a concrete material class.
Is there an easier way to do this?

You’re using the first FilterByBoolMask correctly but then you’re sending the output into the next FilterByBoolMask. You want to use the same bool list from List.Equals on your element filter.

Thanks Nick_Boyts for your help!

I am not sure I completely understand what you are suggesting. I’m still new to Dynamo. Are you suggesting that I plug the List.Flatten node directly into the List.FilterByBoolMask? If I do this I get 24 materials. There are only around 6 elements on the 1st floor that are concrete. Did I understand you correctly?

In your OP you had the All Elements of Level (correct) going into FilterByBoolMask with FilterByBoolMask (incorrect). In your most recent post you changed both inputs.
3f43daab024b0b2741b102a70d939777af1b9acd_1_690x425

You’re going to want to get rid of the List.Flatten and replace List.Equals with List.ContainsItem with the list input @L2. Elements can have multiple materials so flattening the list from Element.GetMaterials is going to give you unequal length lists for your list and mask inputs.

2 Likes

Thanks Nick! That works great!

Thanks awilliams,

Please let me know if I understand your reasoning correctly. I should use List.Contains instead of List.Equals, because an element could have more than 1 material? By not flattening the list first we make sure we can filter through all relevant elements?

Thanks again! I’m trying to learn how to think like a programmer. :grin:

Yes, because you need to have the same number of booleans as you have elements to filter. Each sublist in the Element.GetMaterials output are the materials for each element, so if some elements have 2 materials and some only 1, your total list of materials when flattened will be greater than the number of elements you need to filter, and the indices of the boolean values from List.IsEqual will no longer align with the indices of the elements you are filtering. Hope that wasn’t too wordy :see_no_evil:

Here is the Dynamo dictionary explanation of List.FilterByBoolMask that might clarify for you more: Dynamo Dictionary

Also if you haven’t already, I definitely suggest going through the Dynamo Primer :slight_smile:

2 Likes