Set material to a family intance

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I´m trying to change the material aplly to a familyinstance using the Revit API C# Language. Below is the code, I can chage other parameters in the family but does not work in the same way for the material. Anyone can give me a Help?
Parameter pMatSimbolo = pinElemento.LookupParameter("Cor3DSimbolo");
var sTyMatSimbolo = pMatSimbolo.StorageType.ToString();
var IdMatSimbolo = pMatSimbolo.AsElementId();
Element eleMatSimbolo = doc.GetElement(IdMatSimbolo);
Parameter paramCorSimbolo = eleMatSimbolo.get_Parameter(BuiltInParameter.MATERIAL_NAME);
var xxxxx = paramCorSimbolo.AsString();
FilteredElementCollector nomeMaterial = new FilteredElementCollector(doc);
var material = nomeMaterial.WherePasses(new ElementClassFilter(typeof(Material))).Cast<Material>().First(x => x.Name == ".MVermelho");
ElementId matId = material.Id;
String matNome = material.Name;
pinElemento.Set(".MVermelho");
//------------Retorna de paramentros
TaskDialog.Show("Valor do parametro", vSatus.ToString() + "\n"
+ vDeslo.ToString() + "\n"
+ vSimbolo.ToString());
TaskDialog.Show("Valor do parametro", sTyMatSimbolo.ToString() + "\n"
+ IdMatSimbolo.ToString() + "\n"
+ paramCorSimbolo.ToString() + "\n"
+ xxxxx + "\n"
+ matId.ToString() + "\n"
+ matNome.ToString());