Node Element.GetMaterials does not work properly


I try to retrieve the materials of all elements with Dynamo, but somehow I cannot do this for all elements.

In the picture an example of a Railing that does contain a material but Dynamo cannot find it in any way I try.

Anyone have any idea what I’m doing wrong or how I could fix this?

Try to make the family " Shared" if possible.

Hi Marcel,

The family is Shared so this shouldn’t be the problem.

Try getting the materials from the FamilyType instead of the instance.

In the picture you can see that i tried both but to no avail

Yup. Don’t know how I missed that…

Those nodes only return builtin parameters. For family parameters you’ll have to manually query each parameter.

1 Like

aha … that could be the reason.

With the script I want to check third-party models if all elements are provided with a material.

So that parameter name is never a fixed name …

Is there another way to get this done?

Perhaps something is possible with the Material Parameter Type?

You would have to check the instance and type parameters separately but you could get the ParameterType from all the element parameters and filter out only the Material ones.

1 Like

This may be the solution for my script. I’m going to try it tomorrow and let you know. Thanks Nick!

This seems to work well.
Thanks for your help Nick!

is there maybe a way to process this node in a code block?


Select the node and then right-click on the background somewhere. Click Node to Code and Dynamo will convert the selected node(s) to design script if possible.

I tried that but then Dynamo gave an error …

What was the error?

I tried it in a New Workspace and there he gave no error but no code.