Multiple Rule Filters: Set AND/OR

Hello!

I’m working on a graph that will attribute color overrides via Rule Based Filters to ceilings based on the Type and the Height Offset from Level.

I’m coming across two issues, one is that I’d like for the Project Fill Pattern to apply to the Background rather than the Foreground. Second is that when the filters are created, it’s using “OR” rather than “AND” - is there a way to switch it to all be AND?

Many thanks!

Sorry, this post is not going to be super helpful, but will hopefully get you moving in the correct direction.

Looking at the API all of the access is there, but it looks like that node has not been set up with them. I would recommend either finding a different node or creating one in Python.

This picked my interest a bit and I was able to create a band aid for you.

import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
from Autodesk.Revit.DB import OverrideGraphicSettings

def ensure_list(input_data):
  if not isinstance(input_data, list):
    return [input_data]
  else:
    return input_data

prop = ensure_list(IN[0])
backColor = ensure_list(IN[1])
backPattern = ensure_list(IN[2])

sample = []
for p, bc, bp in zip(prop,backColor,backPattern):
    sample.append(type(bc))
    sample.append(bp)
    if bc:
        p.SurfaceBackgroundPatternColor = bc
    if bp:
        p.SurfaceBackgroundPatternId = bp

OUT = prop

The python above just takes the Override that you already have and sets the properties that are missing. I hope this does the trick for you.

2 Likes

Thanks, I decided that python was the way to go as you suggested. I made both the filters and the overrides directly rather than using the nodes and modifying with some code.

Sharing my code (I’m sure it could be better, I’m a very basic beginner):

import sys
import clr
clr.AddReference(‘RevitAPI’)
clr.AddReference(‘RevitServices’)
from Autodesk.Revit.DB import *
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from System.Collections.Generic import List

doc = DocumentManager.Instance.CurrentDBDocument

cats = ListElementId
cats.Add(ElementId(BuiltInCategory.OST_Ceilings))

names = IN[0]
clgType = IN[1]
clgHeights = IN[2]

color = IN[3]
pattern = UnwrapElement(IN[4])
view = UnwrapElement(IN[5])

#even out lists for zipping
typeNamesMulti =
clgHeightsFlat =
for index, x in enumerate(clgHeights):
for y in x:
typeNamesMulti.append(clgType[index])
clgHeightsFlat.append(y)

#make color overrides per type
prop =

for x in color:
ogs = OverrideGraphicSettings()
ogs.SetSurfaceBackgroundPatternColor(x)
ogs.SetSurfaceBackgroundPatternId(pattern.Id)
prop.append(ogs)

TransactionManager.Instance.EnsureInTransaction(doc)

for nam,tyNam,hOff, override in zip(names, typeNamesMulti, clgHeightsFlat, prop):

pvp = ParameterValueProvider(ElementId(BuiltInParameter.SYMBOL_NAME_PARAM))
rule_1 = FilterStringRule(pvp, FilterStringEquals(), tyNam)

pvp = ParameterValueProvider(ElementId(BuiltInParameter.CEILING_HEIGHTABOVELEVEL_PARAM))
rule_2 = FilterDoubleRule(pvp, FilterNumericEquals(), hOff, .0001)

rules = List[FilterRule]([rule_1, rule_2])

clg_filter = ElementParameterFilter(rules)
view_filter = ParameterFilterElement.Create(doc, nam, cats, clg_filter)

view.SetFilterOverrides(view_filter.Id,override)

TransactionManager.Instance.TransactionTaskDone()

OUT = “Done”