Dear Ameer,
Thank you for your nice clean reproducible case.
I can reproduce the behaviour you describe and find it rather weird as well, so I submitted it to the development team for further analysis.
I logged the issue REVIT-172990 [Parameter filter with FilterStringContains returns false positive] 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.
This issue is important to me. What can I do to help?
This issue needs to be assessed by our engineering team and prioritised against all other outstanding change requests. Any information that you can provide to influence this assessment will help. Please provide the following where possible:
- Impact on your application and/or your development.
- The number of users affected.
- The potential revenue impact to you.
- The potential revenue impact to Autodesk.
- Realistic timescale over which a fix would help you.
- In the case of a request for a new feature or a feature enhancement, please also provide detailed Use cases for the workflows that this change would address.
This information is extremely important. Our engineering team have limited resources, and so must focus their efforts on the highest impact items. We do understand that this will cause you delays and affect your development planning, and we appreciate your cooperation and patience.
I cleaned up your code and submitted it in the following form as TestFilterStringContains:
public void TestFilterStringContains( Document doc )
{
BuiltInParameter bip = BuiltInParameter.FIRE_RATING;
ElementId pid = new ElementId( bip );
ParameterValueProvider provider
= new ParameterValueProvider( pid );
FilterStringRuleEvaluator evaluator
= new FilterStringContains();
FilterStringRule rule = new FilterStringRule(
provider, evaluator, "/", false );
ElementParameterFilter filter
= new ElementParameterFilter( rule );
var myWalls = new FilteredElementCollector( doc )
.OfCategory( BuiltInCategory.OST_Walls )
.WherePasses( filter );
List<ElementId> false_positive_ids
= new List<ElementId>();
foreach( Element wall in myWalls )
{
Parameter param = wall.get_Parameter( bip );
if( null == param )
{
false_positive_ids.Add( wall.Id );
}
}
string s = string.Join( ", ",
false_positive_ids.Select<ElementId, string>(
id => id.IntegerValue.ToString() ) );
TaskDialog dlg = new TaskDialog( "False Positives" );
dlg.MainInstruction = "False filtered walls ids: ";
dlg.MainContent = s;
dlg.Show();
}
It displays a message like this in your sample model:
You might be able to achieve the desired result by combining the FilterStringContains evaluator with other rules and filters.
For instance, you may be able to add something like 'is not empty' in addition to 'contains'.
I hope this helps.
Best regards,
Jeremy