Python Script Graphic Override not assigned to Spaces

There’s been some success using this script (with walls) in a Sample Model.

Script is based on Autodesk link: http://help.autodesk.com/view/RVT/2014/ENU/?guid=GUID-B6FB80F2-7A17-4242-9E95-D6056090E85B

trans = Transaction(doc, “Space Graphics Filled”)
trans.Start()
categories = List[ElementId()
categories.Add(ElementId(BuiltInCategory.OST_MEPSpaces))
parameterFilterElement = ParameterFilterElement.Create(doc, “Filtering parameters”, categories)

parameterCollector = FilteredElementCollector(doc, view.Id)
parameter = parameterCollector.OfClass(SpatialElement).OfCategory(BuiltInCategory.OST_MEPSpaces).FirstElement().LookupParameter(“Comments”)

filterRules = List[FilterRule()
filterRules.Add(ParameterFilterRuleFactory.CreateNotEqualsRule(parameter.Id, “foo”, True))
parameterFilterElement.SetRules(filterRules)

filterSettings = OverrideGraphicSettings()
#outline walls in red
filterSettings.SetProjectionFillColor(Color(255, 0, 0))
view.SetFilterOverrides(parameterFilterElement.Id, filterSettings)

trans.Commit()

The cause of the problem was that the spaces had no graphics to override (being blank).

I found a way around this using Solid Filled Regions to mimic a colour filter.

Do let me know if you’d like to see the code used.