Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Change color by element id + color palette

3 REPLIES 3
Reply
Message 1 of 4
mahmoodha
3010 Views, 3 Replies

Change color by element id + color palette

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.

3 REPLIES 3
Message 2 of 4
gopinath.taget
in reply to: mahmoodha

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

Message 3 of 4
mahmoodha
in reply to: mahmoodha

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.

Message 4 of 4
R.van.den.Bor
in reply to: mahmoodha

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

Kind regards,
Remy van den Bor
ICN Solutions B.V.
Liked this post or found it usefull, don't forget the Kudo It won't hurt (at least not me).

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community