from Autodesk.Revit.DB import *
doc = __revit__.ActiveUIDocument.Document
view = doc.ActiveView
walls_in_view = FilteredElementCollector(doc, doc.ActiveView.Id) \
.OfCategory(BuiltInCategory.OST_Walls) \
.WhereElementIsNotElementType() \
.ToElements()
color_yellow = Color(255,255,0)
color_red = Color(255,0,0)
color_blue = Color(0,0,255)
all_patterns = FilteredElementCollector(doc).OfClass(FillPatternElement).ToElements()
solid_pattern = [i for i in all_patterns if i.GetFillPattern().IsSolidFill][0]
line_patterns = FilteredElementCollector(doc).OfClass(LinePatternElement).ToElements()
random_line_pattern = line_patterns[0]
lineweight = 5
override_settings = OverrideGraphicSettings()
override_settings.SetSurfaceForegroundPatternId(solid_pattern.Id)
override_settings.SetSurfaceForegroundPatternColor(color_yellow)
override_settings.SetCutForegroundPatternId(solid_pattern.Id)
override_settings.SetCutForegroundPatternColor(color_yellow)
override_settings.SetProjectionLineColor(color_red)
override_settings.SetProjectionLinePatternId(random_line_pattern.Id)
override_settings.SetProjectionLineWeight(lineweight)
override_settings.SetCutLineColor(color_red)
override_settings.SetCutLinePatternId(random_line_pattern.Id)
override_settings.SetCutLineWeight(lineweight)
override_settings.SetSurfaceTransparency(50)
with Transaction(doc, 'Override Colours') as t:
t.Start()
for wall in walls_in_view:
view.SetElementOverrides(wall.Id, override_settings)
t.Commit()
__author__ = '🙋♂️ Erik Frits'