Filter Rule data – where is it hiding?

It is in there, but you’ve got to dig into some sub-classes and static functions.

This doesn’t implement every case, hopefully is enough to shed some light on how it works.

public void ListFilters()
{
    Document doc = this.ActiveUIDocument.Document;
    foreach (ParameterFilterElement pfe in new FilteredElementCollector(doc).OfClass(typeof(ParameterFilterElement)).Cast<ParameterFilterElement>())
    {        
        string ruleData = "";                    
        string categories = "";
            
        foreach (ElementId catid in pfe.GetCategories())
        {
            categories += doc.Settings.Categories.get_Item(((BuiltInCategory)catid.IntegerValue)).Name + ",";
        }
                 
        foreach (FilterRule rule in pfe.GetRules())
        {
            string comparator = "";
            string ruleValue = "";

            if (rule is FilterDoubleRule)
            {
                FilterDoubleRule fdr = rule as FilterDoubleRule;
                
                if (fdr.GetEvaluator().GetType().Equals(typeof(FilterNumericLess)))
                    comparator = "<";
                else if (fdr.GetEvaluator().GetType().Equals(typeof(FilterNumericGreater)))
                    comparator = ">";
                
                ruleValue = fdr.RuleValue.ToString();

            }
            else if (rule is FilterStringRule)
            {
                FilterStringRule fsr = rule as FilterStringRule;
                
                if (fsr.GetEvaluator().GetType().Equals(typeof(FilterStringBeginsWith)))
                    comparator = "starts with";
                else if (fsr.GetEvaluator().GetType().Equals(typeof(FilterStringEndsWith)))
                    comparator = "ends with";
                else if (fsr.GetEvaluator().GetType().Equals(typeof(FilterStringEquals)))
                    comparator = "=";
                else if (fsr.GetEvaluator().GetType().Equals(typeof(FilterStringContains)))
                    comparator = "contains";
                
                ruleValue = fsr.RuleString;
            }
            else if (rule is FilterIntegerRule)
            {
                FilterIntegerRule fir = rule as FilterIntegerRule;
                
                if (fir.GetEvaluator().GetType().Equals(typeof(FilterNumericEquals)))
                    comparator = "=";
                else if (fir.GetEvaluator().GetType().Equals(typeof(FilterNumericGreater)))
                    comparator = ">";
                
                // some parameters store an integer but the UI shows a text string
                // this text comes from the value of an enum such as WallFunction
                if (((BuiltInParameter)ParameterFilterElement.GetRuleParameter(rule).IntegerValue) == BuiltInParameter.FUNCTION_PARAM)
                {
                    ruleValue = ((WallFunction)fir.RuleValue).ToString();
                }
                else
                    ruleValue = fir.RuleValue.ToString();
            }
            
            string paramName = "";
            if (ParameterFilterElement.GetRuleParameter(rule).IntegerValue < 0)
                paramName = LabelUtils.GetLabelFor((BuiltInParameter)ParameterFilterElement.GetRuleParameter(rule).IntegerValue);
            else
                paramName = doc.GetElement(ParameterFilterElement.GetRuleParameter(rule)).Name;

            
            ruleData += "'" + paramName + "' " +
                comparator + " " +
                "'" + ruleValue.ToString() + "'" +
                Environment.NewLine;
        }
        TaskDialog td = new TaskDialog("Rule");
        td.MainInstruction = "Filter name: " + pfe.Name;
        td.MainContent = "Categories: " + categories + Environment.NewLine + Environment.NewLine + ruleData;
        td.Show();
    }
}

Revit Lookup 2017 Installer

If you want to experience the joys of Revit Lookup (the interactive Revit BIM database exploration tool) on Revit 2017 without downloading the source code and compiling it yourself, you can download an installer for it at https://drive.google.com/open?id=0BwszsfY3OsZHSG5yaGdhejcyNkk

Capture

Code Signing For Revit 2017

In 2017, Autodesk really wants developers to sign their DLLs (http://thebuildingcoder.typepad.com/blog/2016/04/whats-new-in-the-revit-2017-api.html#2.4)

If you don’t, Revit will show this scary dialog on startup

not signed

Dealing with this was a fairly annoying process, so to hopefully make it easier for others, here is what I did.

  1. Bought a 5 year certificate from http://codesigning.ksoftware.net/ for $365
  2. Sent them a bunch of documentation to prove that I am who I say I am (including signing up for a free listing at http://www.yellowpages.com/allston-ma/mip/boost-your-bim-526332700?lid=526332700)
  3. Got my “certificate” and generated a PFX file (if you have questions about this step, post in the comments and I will add more info)
  4. Added this to the Visual Studio post build event
    “C:\Program Files (x86)\Windows Kits\8.0\bin\x64\signtool.exe” sign /f “C:\Users\harry_000\Documents\Boost Your BIM\BoostYourBIM.pfx” /t “http://timestamp.comodoca.com/authenticode&#8221; /p <password> /v $(TargetPath)

The result is that the DLL has a signature as shown below.

properties