Hello everyone:
I am trying change the color a element but the following code not work. I am using Revit 2015. The element is "Parts".
For to change to color I am using a foreach:
FilteredElementCollector collector = new FilteredElementCollector(m_revit.ActiveUIDocument.Document).OfClass(typeof(FamilyInstance)); foreach (FamilyInstance fi in collector) { Color color = m_revit.ActiveUIDocument.Application.Application.Create.NewColor(); color.Blue = ( byte ) 150; color.Red = ( byte ) 200; color.Green = ( byte ) 200; doc.ActiveView.set_ProjColorOverrideByElement(fi.Id, color); }
set_ProjColoOverrideByElement is deprecate in Revit 2015?
Thank's for you help.
Regards,
David
Solved! Go to Solution.
Solved by augusto.goncalves. Go to Solution.
Here goes:
UIApplication uiapp = commandData.Application;
UIDocument uidoc = uiapp.ActiveUIDocument;
Application app = uiapp.Application;
Document doc = uidoc.Document;
Color color = app.Create.NewColor();
color.Blue = (byte)150;
color.Red = (byte)0;
color.Green = (byte)0;
Selection sel = uidoc.Selection;
Reference ref1 = sel.PickObject(
ObjectType.Element,
"Pick element to change its colour");
Element elem = doc.GetElement(ref1.ElementId);
List<ElementId> ids = new List<ElementId>(1);
ids.Add(elem.Id);
Transaction trans = new Transaction(doc);
trans.Start("ChangeColor");
doc.ActiveView.set_ProjColorOverrideByElement(ids, color);
trans.Commit();
Thanks & Regards
Sanjay Pandey
Hello,
I am using this code and not works with the parameters element Id and color. I'm doing wrong?.
if (category == "Parts")
{
FilteredElementCollector collector = new FilteredElementCollector(m_revit.ActiveUIDocument.Document).OfClass(typeof(FamilyInstance));
int i = 0;foreach (FamilyInstance fi in collector) { //Get parameters //Perforacion y cableado Parameter perforacion = fi.LookupParameter("Dia Planeado de Perforacion e Inyeccion"); //Perfilado Parameter perfilado = fi.LookupParameter("Dia Planeado de Perfilado"); //Acero Parameter acero = fi.LookupParameter("Dia Planeado de Colocacion de Acero"); //Encofrado Parameter encofrado = fi.LookupParameter("Dia Planeado de Encofrado"); //Concreto Parameter concreto = fi.LookupParameter("Dia Planeado de Concreto"); //Tensado Parameter tensado = fi.LookupParameter("Dia Planeado de Tensado");
if (ParameterToString(perforacion).Equals(day)) { //change to color: Celeste Color color = m_revit.ActiveUIDocument.Application.Application.Create.NewColor(); color.Blue = ( byte ) 150; color.Red = ( byte ) 200; color.Green = ( byte ) 200; m_revit.ActiveUIDocument.Document.ActiveView.SetElementOverrides(fi.Id, color); } }
}
}
Regards,
David
Hello Augusto:
Thank's very much for respond.
The code not have errores but the execute in Revit displays the following message:
I not understand the problem in this point.
The Code:
foreach (Part fi in collector){ ...........
if (ParameterToString(perforacion) == day) { TaskDialog.Show("GYM-BIM", "Color Celeste = " + day); //change to color: light blue Color color = m_revit.ActiveUIDocument.Application.Application.Create.NewColor(); color.Blue = (byte)255; color.Red = (byte)0; color.Green = (byte)255; OverrideGraphicSettings ogs = new OverrideGraphicSettings(); ogs.SetProjectionLineColor(color); // or other here m_revit.ActiveUIDocument.Document.ActiveView.SetElementOverrides(fi.Id, ogs); }
Regards,
David
Augusto:
Thank's very much. Now works very good.
Regards,
David