Have Revit files to upgrade to 2017 and want to do it quickly and easily?
If you don’t want to wait for the new version of File Upgrader to be available at the Autodesk Store, get it here.
Have Revit files to upgrade to 2017 and want to do it quickly and easily?
If you don’t want to wait for the new version of File Upgrader to be available at the Autodesk Store, get it here.
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();
}
}
If you want to experience the joys of Revit Lookup (the interactive Revit BIM database exploration tool) on Revit 2017 or 2018 without downloading the source code and compiling it yourself, you can download an installer for it at https://drive.google.com/open?id=0BwszsfY3OsZHSG5yaGdhejcyNkk
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
Dealing with this was a fairly annoying process, so to hopefully make it easier for others, here is what I did.
The result is that the DLL has a signature as shown below.