Change Graphic Overrides of an Element in View

#⬇️ IMPORTS
from Autodesk.Revit.DB import *

#📦 Variables
doc = __revit__.ActiveUIDocument.Document
view = doc.ActiveView

walls_in_view = FilteredElementCollector(doc, doc.ActiveView.Id) \
        .OfCategory(BuiltInCategory.OST_Walls) \
        .WhereElementIsNotElementType() \
        .ToElements()


#🎨 COLORS
color_yellow = Color(255,255,0)
color_red    = Color(255,0,0)
color_blue   = Color(0,0,255)

#🧱 GET PATTERNS
all_patterns  = FilteredElementCollector(doc).OfClass(FillPatternElement).ToElements()
solid_pattern = [i for i in all_patterns if i.GetFillPattern().IsSolidFill][0]

#〰️ LINES
line_patterns       = FilteredElementCollector(doc).OfClass(LinePatternElement).ToElements()
random_line_pattern = line_patterns[0]
lineweight          = 5


#⚙️ CREATE OVERRIDE SETTINGS
override_settings = OverrideGraphicSettings()

#⚙️ SURFACE FOREGROUND (PATTERN + COLOR)
override_settings.SetSurfaceForegroundPatternId(solid_pattern.Id)
override_settings.SetSurfaceForegroundPatternColor(color_yellow)

#⚙️ CUT FOREGROUND ( PATTERN + COLOR)
override_settings.SetCutForegroundPatternId(solid_pattern.Id)
override_settings.SetCutForegroundPatternColor(color_yellow)

#⚙️ PROJECTION LINES (Extra)
override_settings.SetProjectionLineColor(color_red)
override_settings.SetProjectionLinePatternId(random_line_pattern.Id)
override_settings.SetProjectionLineWeight(lineweight)

#⚙️ CUT LINES (Extra)
override_settings.SetCutLineColor(color_red)
override_settings.SetCutLinePatternId(random_line_pattern.Id)
override_settings.SetCutLineWeight(lineweight)

#⚙️ SET TRANSPARENCY
override_settings.SetSurfaceTransparency(50)


#🎯 MAIN
with Transaction(doc, 'Override Colours') as t:
    t.Start()

    #👉 OVERRIDE ELEMENT GRAPHICS IN ACTIVE VIEW
    for wall in walls_in_view:
        view.SetElementOverrides(wall.Id, override_settings)

    t.Commit()

__author__ = '🙋‍♂️ Erik Frits'

⌨️ Happy Coding!
Erik Frits