Depreciated ParameterFilterElement.SetRules - Small Documentation Error

Depreciated ParameterFilterElement.SetRules - Small Documentation Error

grahamcook
Advocate Advocate
1,566 Views
5 Replies
Message 1 of 6

Depreciated ParameterFilterElement.SetRules - Small Documentation Error

grahamcook
Advocate
Advocate

Hi

Was just migrating some code from 2018 to 2020 and was replacing the depreciated ParameterFilterElement.SetRules method with ParameterFilterElement.SetElementFilter.  I looked at the documentation for some guidance:

https://www.revitapidocs.com/2019/b231dc85-516a-5e75-c634-c6cd81b43fc5.htm

The c# example refers to a method (CreateElementFilterFromFilterRules) that does not exist.  The line:

 

ElementFilter elemFilter = CreateElementFilterFromFilterRules(filterRules);

needs replacing with:

List<ElementFilter> elemFilters = new List<ElementFilter>();
foreach (FilterRule filterRule in filterRules)
{
    ElementParameterFilter elemParamFilter = new ElementParameterFilter(filterRule);
    elemFilters.Add(elemParamFilter);
}

LogicalAndFilter elemFilter = new LogicalAndFilter(elemFilters);

Thanks.

1,567 Views
5 Replies
Replies (5)
Message 2 of 6

jeremytammik
Autodesk
Autodesk

Dear Graham,

 

Thank you for your report and sharing the workaround.

 

Sorry to hear about this.

 

I logged the issue REVIT-149071 [API documentation error: ParameterFilterElement Class: CreateElementFilterFromFilterRules] with our development team for this on your behalf as it requires further exploration and possibly a modification to our software. Please make a note of this number for future reference.

 

You are welcome to request an update on the status of this issue or to provide additional information on it at any time quoting this change request number.

 

By the way, 'deprecated' has no 'i' in it  🙂

  

Here are another couple of samples of using filter rules:

 

https://thebuildingcoder.typepad.com/blog/2019/05/filtered-element-collector-benchmark.html

  

Best regards,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 3 of 6

Anonymous
Not applicable

Hey. This code still doesn’t work for me.

LogicalAndFilter elemFilter = new LogicalAndFilter(elemFilters);

How to further apply this LogicalAndFilter in view?

 
0 Likes
Message 5 of 6

Anonymous
Not applicable

I thought this code should add a filter to the view. For 2020 version
LogicalAndFilter is about it?

0 Likes
Message 6 of 6

Dronov.Dmitry
Advocate
Advocate
0 Likes