I am looking for a existing property/function to change element color by id.
I tried using set_ProjColorOverrideByElement and it changes only the element's border color. I am curious to know about set_ProjLinePatternOverrideByElement. Setting the LinePatternElement to something like "solidfill", may help. Also please let me know if there is any other way to change the element color.
Also I need help with implementing the color palette.
I am new to Revit API, though I have hands-on experience in C#.
I would appreciate your prompt reply.
Hello,
It looks to me that you want to change the color inside an element. Now depending on the type of element this may or may not make sense. What kind of elements are you working with that you want to change internal color for? Are you able to change the colors using the UI? Typically, if you cannot do something with the UI, you cannot do it with the API either.
Thanks
Gopinath
Yes, I am trying to implement something which can be done in UI.
Right click on a wall --> Override Graphic in View --> By Element --> SurfacePattern --> choose color, Pattern - solid fill.
Please let me know how we can implement this for a element(given element id) from API.
Hello,
maybe this will help.
I once needed it for all walls in a project, where the user could choose with checkboxes what he wanted to change.
The chkblabla are the checkboxes and cmbRAL is the combobox with ral colours.
ICollection<ElementId> ids = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Walls).WhereElementIsNotElementType().ToElementIds();
Element El = null;
Element ma = null;
Material mater = null;
List<Element> TheMaterials = ElementCollectionHelper.GetAllProjectElements(doc).Where(c => c.GetType() == typeof(Material)).ToList();
foreach (ElementId elid in ids)
{
OverrideGraphicSettings org = new OverrideGraphicSettings();
if (chkProjLines.Checked) org.SetProjectionLineColor(SystemToRevitColor(cmbRAL.SelectedItem.ToString()));
if (chkSurfPatt.Checked) org.SetProjectionFillColor(SystemToRevitColor(cmbRAL.SelectedItem.ToString()));
if (chkCutLines.Checked) org.SetCutLineColor(SystemToRevitColor(cmbRAL.SelectedItem.ToString()));
if (chkCutPatt.Checked) org.SetCutFillColor(SystemToRevitColor(cmbRAL.SelectedItem.ToString()));
doc.ActiveView.SetElementOverrides(elid, org);
Element ele = doc.GetElement(elid);
ICollection<ElementId> Lmats = ele.GetMaterialIds(false);
foreach (ElementId mat in Lmats)
{
ma = TheMaterials.Find(a => a.Id == mat);
mater = ma as Material;
mater.Color = SystemToRevitColor(cmbRAL.SelectedItem.ToString());
}
Can't find what you're looking for? Ask the community or share your knowledge.