Issue with filtering elements by material

Hey all,

I feel like i am losing it.

I am trying to get a general idea how much concrete is being used in my project. To do this I am gathering all elements of the types Wall, Floor and Column, the next step is to get the element’s materials and filter out the material so only concrete remains.

I thought everything was working fine until i noticed the sum is significantly less than expected.

The weird thing is, I noticed a floor was missing in the filtered list but i can’t figure out why.
Below is my complete script:

In the red or pink groups I am trying to figure out why this particular wall is not being added to the sum, it gets filtered out at the material comparison even though when filtered on its own, it sees that the material matches my filter.

For your readability step by step:

(1) Gathering all elements in project with certain type

(2) Filtering out all elements that arent using the material Concrete(translated)

(3) Calculating total volume This is where I accidentally noticed that volume is missing

(4) Select model element in project and make sure its in the other list


(5) Try to filter this specific element’s material and match it to material used in other fitler

How is it possible that when filtering a big list, this element gets put in the ‘Out’ output, but when i use the exact same nodes to filter the element by itself, it gets put in the ‘In’ output node?

Am i missing something here? I have been looking at this for a while now and i cant figure it out…

I just now notice that the Element.GetMaterials adds multiple materials for layered elements… :man_facepalming:

Elements return a list of materials. You’re flattening the materials list (3140) and then comparing that to the elements list (3078). Those lists do not match. You need to check the list of materials and filter for any matches first. That will give you all elements that contain your material. Then you can get the specific material and its properties (volume).

1 Like

Heh i feel dumb typing all that out now…

Thanks Nick, i will implement your suggestions :slight_smile: