Filter list to get just value of a certain property

Hello, Community,

I am writing a dynamo graph to calculate COG taking into account different materials. Materials have been applied to objects that include “Physical” properties including “Density.” I have the list of physical properties of the objects, but I’m stuck on how to filter the list to just get the density of each object. Can anyone help?

Thanks,

Chuck

@Chuck.Ross ,

use classic “Material” → GetParameterByNameAndValue → groupByKey →

KR

Andreas

The structural properties of a material are from their Structural Asset, which is not part of the immediate material element. You would either have to go through the API to get it or you could just use a generic filter for the name of the property/parameter.

This seems like a super hacky way to do this, but it works. Don’t forget that each set of material properties is itself a list and therefore you need to use the “Levels” function of the nodes.

Material.StructuralParameters → Parameter.Name → List.IndexOf (for the “Density” parameter) → List.GetItemAtIndex → Parameter.Value

I look forward to learning a more elegant way to accomplish this.

1 Like

FilterByBoolMask would probably be easier just because it handles the list levels for you. You’d also need to use list levels for the index of GetItemAtIndex, but otherwise a fine solution.

Not to beat a dead horse, but you can simplify the filtering down some by using the codeblock along with FilterByBoolMask as @Nick_Boyts stated

2 Likes

Thank you @staylor and @Nick_Boyts - That does look cleaner.

What is the Element.MaterialCollector node? - is that from a downloaded package?

Thanks,

Chuck

Yes it’s from Universo_BIM package. Or you can use the Element.GetMaterials node that you already have.