# Element override material in view

**URL:** <https://forum.dynamobim.com/t/element-override-material-in-view/20035>\
**Category:** Revit\
**Created:** [March 14, 2018, 2:38pm UTC](https://forum.dynamobim.com/t/element-override-material-in-view/20035 "2018-03-14T14:38:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![robert.ek](https://avatars.discourse-cdn.com/v4/letter/r/ecae2f/32.png) [@robert.ek](https://forum.dynamobim.com/u/robert.ek)\
**Post date:** [March 14, 2018, 2:38pm UTC](https://forum.dynamobim.com/t/element-override-material-in-view/20035/1 "2018-03-14T14:38:30Z")

</div>

Hi,  
I am trying to create a script to easily change an element’s material such as Element.OverrideColorInView But with a material instead of a color.  
Any suggestions? Best

 ![example](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/e/9e0f92a9367f64fd47bed4d330032a146a6f5f2b.png)

---

<div class="post-metadata">

**Author:** ![3Pinter](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/3pinter/32/74327_2.png) [@3Pinter](https://forum.dynamobim.com/u/3Pinter)\
**Post date:** [March 14, 2018, 4:27pm UTC](https://forum.dynamobim.com/t/element-override-material-in-view/20035/2 "2018-03-14T16:27:41Z")

</div>

To my knowledge you can’t override a material (with another material).

If you have to change an element’s material I would suggest using the paint-option.

---

<div class="post-metadata">

**Author:** ![robert.ek](https://avatars.discourse-cdn.com/v4/letter/r/ecae2f/32.png) [@robert.ek](https://forum.dynamobim.com/u/robert.ek)\
**Post date:** [March 14, 2018, 5:00pm UTC](https://forum.dynamobim.com/t/element-override-material-in-view/20035/3 "2018-03-14T17:00:09Z")

</div>

I have here an example using a paint method with py. script by René Castillo Picazo.  
The only problem with this is that when the element is painted it can’t be painted again without the paint being removed first.

A Removing paint script or a modification of script below would solve the issue.

```
# Copyright(c) René Castillo Picazo
# México 2017
# cadesigner.mex@gmail.com

import clr

clr.AddReference("RevitAPI")
clr.AddReference("RevitServices")

import Autodesk
import RevitServices

from Autodesk.Revit.DB import *
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

surfaces = IN[0]
material = UnwrapElement(IN[1])

def PaintFace(surf, mat):
elemRef = surf.Tags.LookupTag("RevitFaceReference")
elem = doc.GetElement(elemRef)
face = elem.GetGeometryObjectFromReference(elemRef)

if not (doc.IsPainted(elem.Id, face)):
    return doc.Paint(elem.Id, face, mat.Id)
  

TransactionManager.Instance.EnsureInTransaction(doc)

if (isinstance(surfaces, list)):
[PaintFace(j, material) for i in surfaces for j in i]
else:
PaintFace(surfaces, material)              

TransactionManager.Instance.TransactionTaskDone() 

```

 ![example2](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/1/818df92c5d2a7a5449154231597ca05710be847f.png)
