GetMaterialId method outputs empty list

Hi,

i am trying to get the material information (Id) from a family but within revit and not the family, using the GetMaterialId method: https://www.revitapidocs.com/2020/6011352e-151b-b8ac-14cc-45970f2fe5ad.htm

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:
e.Id.GetMaterialId(True)

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.