Hey Mendo,
I've just done this exact thing in one of my macro's, and i saw this post.
So here's how i do it:
i have a collection.OfClass( FamilyInstance )
i have a matList[]
i have a matNameList[]
then i loop through the project
for f in collection:
paraMaterial = f.Symbol.get_Parameter( BuiltInParameter.STRUCTURAL_MATERIAL_PARAM )
material = doc.GetElement( paraMaterial.AsElementId() )
if material != None:
if material.Name not in matNameList:
matNameList.Add( material.Name )
matList.Add( material )
after going through this loop your matList[] contains all the materials used in the project (only one instance of every material)
if you want to assign a material you can use this format:
paraMaterial.Set( material.Id ) # paraMaterial contains your familyInstance reference, and material can be an item in your list.
Hope this helps you ;)