How to add Does not contain filter rule, and solid color

Hi, im using Revit 2021
1- I am trying to create a filter that uses a rule of 'does not contain, and it seems there is no class FilterStringDoesNotContain for that.

2- in addition, I successfully created a filter that colors elements in green, but i cant get it to color the elements in a solid pattern.

image

can you guys help me with these 2 things please?
thank you

........
pvp = ParameterValueProvider(param.Id)

# remember. rule_1 and rule_2 belongs to separate filters and do not go on the same List[FilterRule]()

rule_1 = FilterStringRule(pvp, FilterStringEquals(), 'some value', True)
# This  is suppose to be the does not contain rule
rule_2 = FilterStringRule(pvp, FilterString?????)

rules_1 = List[FilterRule]([rule_1])
rules_2 = List[FilterRule]([rule_2])

filter_1 = ElementParameterFilter(rules)

view_filter = ParameterFilterElement.Create(doc, filter_1_name, categories, filter_1)

# overrides for filter

rgb_green = Color(0, 255, 0)

# rgb_orange = Color(255, 128, 54)

overrideSettings_rule_1 = OverrideGraphicSettings()

overrideSettings_rule_1.SetSurfaceForegroundPatternColor(rgb_green)

overrideSettings_rule_1.SetProjectionLineColor(rgb_green)

active_view = doc.ActiveView

active_view.AddFilter(view_filter.Id)

active_view.SetFilterOverrides(view_filter.Id, overrideSettings_rule_1)

t.Commit()

1.Its been a while since I’ve done anything with filters in the API but if i recall you use the FilterInverseRule class in conjunction with your FilterStringContains method to achieve what your after?

  1. Simple fix - you’re missing a step to set the appropriate fill patterns using the SetSurfaceForegroundPatternId method. The override is not ‘solid’ by default, as with a filter you may want to change the color of the pattern but not the pattern itself.

To get the 'Solid Fill" pattern id you can use the GetFillPatternElementByName method

Hi and thanks for your answer.

  1. Worked well! thank you.
  2. can you please elaborate? I see that the method ‘GetFillPatternElementByName’ belongs to the class ‘FillPatternElement’ Class but Im not sure on how to get to it.
    thanks

you just reference it directly from the DB. This can be either using pyRevits implementation (per below if you import DB from pyRevit, or using Autodesk’s directly, in which case you would remove the “DB.” prefix)

DB.FillPatternElement.GetFillPatternElementByName(doc, DB.FillPatternTarget.Drafting, "Add Name Of Fill Pattern Here")