GetMaterialId method outputs empty list


i am trying to get the material information (Id) from a family but within revit and not the family, using the GetMaterialId method:

But the output is a empty list. It should be the ID of Beton - C30/37 (Concrete).

Also when i use the ID of the element(family) for the GetMaterialId() method i get a warning:

The actual goal is to change the material of the family. Maybe someone has any ideas how to do that?

Thanks for the help!

Is there a parameter for the material? If so just set the parameter value. If not you can’t edit the family from inside a project.