Announcements

The Autodesk Community Forums has a new look. Read more about what's changed on the Community Announcements board.

Find family elements by name parameter

ottosson_mathias
Advocate

Find family elements by name parameter

ottosson_mathias
Advocate
Advocate

I'm trying to filter elements by the Name parameter using a FilterStringRule:

 

var elementParameter = new ParameterValueProvider(new ElementId(BuiltInParameter.?????));
var stringContains = new FilterStringContains();
var stringRule = new FilterStringRule(elementParameter, stringContains, "Mullion", false);

var mullionFilterOne = new FilteredElementCollector(doc)
    .OfClass(typeof(Family))
    .WherePasses(new ElementParameterFilter(stringRule));

But this yields no results...

 

I'm getting expected elements using this way instead, but it's potentially a much slower way of getting the elements:

 

var mullionFilterTwo = new FilteredElementCollector(doc)
    .OfClass(typeof(Family))
    .ToElements()
    .Where(x => x.Name.ToLower().Contains("mullion"));

What am I doing wrong? I've tried many different BuiltInParameters but with no success. What BuiltInParameter do I need to check to get the Name parameter of a Family Element?

 

Thanks!

 

0 Likes
Reply
1,920 Views
3 Replies
Replies (3)

jeremytammik
Autodesk
Autodesk

Just examine the element properties in RevitLookup:

 

https://github.com/jeremytammik/RevitLookup

  

Navigate to its parameters, look for the `Name`, look at the parameter definition, and the corresponding built-in parameter will be listed there.

 

Then use that in your filter.

 

Cheers,

 

Jeremy

 



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

0 Likes

ottosson_mathias
Advocate
Advocate

Thanks! It's really good to know how to find those. But I can't seem to find the correct one anyway... It looks like I should use BuiltInParameter.ALL_MODEL_FAMILY_NAME, but it still doesn't give me any results.

 

However. Using the BIP-checker (excellent tool!) I instead found that I can use the BuiltInParameter.SYMBOL_NAME_PARAM, and when I filter combined with the .OfClass(typeof(FamilySymbol)) I get the correct family symbol, which is what I really needed.

 

Thanks again!

0 Likes

jeremytammik
Autodesk
Autodesk

Congratulations on solving your problem and thank you for your appreciation and letting us know.

 

Glad to hear that you found BipChecker useful

 

I think that the parameter storing the element name may vary between different types of elements, unfortunately.

 

Congratulations even more on discovering what you were really trying to do.

 

It always helps a lot to know what you want to achieve before starting to implement a solution  🙂

 

Cheers,

 

Jeremy

 



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

0 Likes