Set material to a family intance

Set material to a family intance

Anonymous
Not applicable
598 Views
3 Replies
Message 1 of 4

Set material to a family intance

Anonymous
Not applicable

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());

 

 

0 Likes
599 Views
3 Replies
Replies (3)
Message 2 of 4

jeremytammik
Autodesk
Autodesk
0 Likes
Message 3 of 4

Anonymous
Not applicable

Thanks Jeremy, I will look at your post about the material discussed in detail, to see if I can solve the problem.

0 Likes
Message 4 of 4

mhannonQ65N2
Collaborator
Collaborator

Element dpes not have a Set method. You probably want to do 

pMatSimbolo.Set(matId);
0 Likes