Collect all used materials/families in the model

Hello there,

I am at the very begining of my Dynamo journey and trying to slowly learn find myself here. I ve been trying to find a solution to my problem on the forum and have read through many posts, but yet didn’t find a good way to solve it.

I was wondering if there is any way to get all used materials in the model, with the help of avaliable nodes?
I managed to collect all materials in the model by using “Element.types” -" All elements of type" nodes, but I wonder if there is any node I could use to get only used materials to be able to later use “List.SetDifference” node for example and delete elements which are unused.

As an example I have found some help to manage to delete all unused view filters before, so started to wonder if it’s possible with unused materials and maybe later on also unused families and groups and so on. Since sometimes I instead of purging all in project, I would like to purge only specific categories and it can be slightly annoying and take a bit of time selecting them one by one.

If you have any ideas, I would really appreciate it.

I am attaching the “Delete unused view filters” script, which I made before, as a reference.

Purge unused view filters.dyn (29.9 KB)

Hi @joanna.g ,

I don’t know if there is a way to find out if a material is used. For familyinstances you could simply get all families with their types and get the familyinstances, if that list is empty you know it is unused.

Thank you so much. I will try this solution for the families