0

I want to create my own Boolean operation on an element to pass in as a FilterRule. The ElementPasses member description states:

Derived classes override this method to implement the test that determines whether the given element passes this rule or not.

I have tried to create my own derived class but I can't figure out how to implement it. I would think an interface would be available but I can't find anything. Annoyingly, I remember seeing an example of this but I can't seem to find anything.

This fails with: Static class 'ParameterDefinitionExists' cannot derive from type 'FilterRule'. Static classes must derive from object.

static public class ParameterDefinitionExists : FilterRule
{
    public static bool ElementPasses(Element element)
    {
        return true;
    }
}

And this fails with:'FilterRule' does not contain a constructor that takes 0 arguments

static public class ParameterDefinitionExists : FilterRule
{
    new public bool ElementPasses(Element element)
    {
        return true;
    }
}

What constructor arguments does it take?

There may be another way to go about it but I can't anything for FilterRules. I'm trying to define and refine a trigger in an updater but maybe I should query the element after it is passed in to the command. I imagine catching it with a filter rule is more efficient.

Barrie
  • 42
  • 1
  • 9

1 Answers1

1

You have to use one of the Revit API classes derived from FilterRule:

Inheritance Hierarchy

  • System Object
    • Autodesk.Revit.DB FilterRule
      • Autodesk.Revit.DB FilterCategoryRule
      • Autodesk.Revit.DB FilterInverseRule
      • Autodesk.Revit.DB FilterValueRule
      • Autodesk.Revit.DB SharedParameterApplicableRule

Cf. http://www.revitapidocs.com/2017/a8f202ca-3c88-ecc4-fa93-549b26a412d7.htm

The Building Coder provides several examples creating and using parameter filters:

http://thebuildingcoder.typepad.com/blog/2010/08/elementparameterfilter-with-a-shared-parameter.html

Here is the entire topic group on filtering.

Jeremy Tammik
  • 7,333
  • 2
  • 12
  • 17