Retrieving all instances of a wall type (Python)

Hi All,

I’m referring to the solution of this post by @Jeremy_Tammik

WallType X;

FilteredElementCollector allWallsOfTypeX
  = new FilteredElementCollector(doc)
    .Where( e => e.WallType.Id.IntegerValue.Equals( X.Id.IntegerValue ) );

Is there a filter (slow or quick) that can be used to replace the last line (Linq) ?

I’ve tried using the following;

FamilyInstanceFilter(doc, Brick230Id)

but I get an error;


Tried that, but it looks like the FamilyInstanceFilter only works with loadable families. It makes sense as System families don’t inherit from FamilySymbol:

Regarding if there is another filter for that purpose, I think what is in there is quite nice.
I haven’t tried a logical filter, but it may work. Although I don’t think it would make the code shorter:

1 Like

@architectcoding Thank you for your reply.

Not sure how you were thinking of making the logical filter work as you have to provide quick/slow filters. See sample code below from @Jeremy_Tammik Github.

      ElementClassFilter f1
        = new ElementClassFilter(
          typeof( FamilyInstance ) );

      ElementCategoryFilter f2
        = new ElementCategoryFilter(
          BuiltInCategory.OST_Doors );

      ElementCategoryFilter f3
        = new ElementCategoryFilter(
          BuiltInCategory.OST_Windows );

      LogicalOrFilter f4
        = new LogicalOrFilter( f2, f3 );

      LogicalAndFilter f5
        = new LogicalAndFilter( f1, f4 );

My bad, though a combination of those filters would yield something, but have tried it and it is not working. In the end I have to use some combination of methods to retrieve those instances as Jeremy did.

1 Like

Yes, the last line can be replaced by a quick filter. You can use a parameter filter. That line is checking the value of the WallType element id. The wall type element id is also accessible from a built-in parameter. So, you can set up a parameter filter that checks for equality with the target wall type element id.


does this work?



Thanks @Jeremy_Tammik !

I found 2 solutions as shown below.


pvp = ParameterValueProvider(ElementId(BuiltInParameter.ELEM_TYPE_PARAM))
fRule = FilterElementIdRule(pvp, FilterNumericEquals(), Brick230.Id)
filter = ElementParameterFilter(fRule)
Brick230Instances = FilteredElementCollector(doc)\

Option 2
fRule = List[FilterRule]()
ParId = ElementId(BuiltInParameter.ELEM_TYPE_PARAM)
fRule.Add(ParameterFilterRuleFactory.CreateEqualsRule(ParId, Brick230.Id))
filter = ElementParameterFilter(fRule)

Brick230Instances = FilteredElementCollector(doc)\

@stillgotme Your code will just retrieve all WallTypes in your project. I’m after instances of a certain wall type.

ops. misunderstood your question :smiley:

eletypes =  FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Walls).WhereElementIsElementType().ToElements()
elety = [eletype for eletype in eletypes  if eletype.Name == "Brick230" ]
eles = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Walls). WhereElementIsNotElementType.ToElements() 
neweles = [ele for ele in eles if ele.GetTypeId() == type.Id ]

can try something like this too :slight_smile:

Thanks @stillgotme! but the point was if it could have been done with a slow/quick filter (not list comprehension) :wink:

ahhh, well the set of solution you provided was new to me too :wink:! im still learning new things everyday! Thanks for sharing

1 Like

Brilliant! Both look good to me.

1 Like

gotta say this line of codes are damn useful too, i just used it in this application:

pipes = ToList(IN[0])
pipeIds = [p.Id for p in pipes]
pipeIDS = List[ElementId](pipeIds)

ParId = ElementId(BuiltInParameter.RBS_PIPING_SYSTEM_TYPE_PARAM)
fRule = List[FilterRule]()
fRule.Add(ParameterFilterRuleFactory.CreateContainsRule(ParId, "Sewerage",False))
filter = ElementParameterFilter(fRule)

filteredpipe = FilteredElementCollector(doc,pipeIDS).WherePasses(filter).ToElements()

to filtered out required system type pipes. Once again thank you for this sample of codes @salvatoredragotta


Not a problem and thank you for sharing your sample code :grinning:

hi , i’m trying to get all of wall types those are exist in “Wall types” node(Dynamo) alltogether, not only those are exist in my revit project , can you help me about that ?
i’ve already have Python in my dynamo . is there any code that i should copy ?


No need for Python.

Element Types (Choose Wall Types) and a All Elements of Type Node should do it.

Thank you I really appreciate your help !

Hello again :slight_smile: i wanna know can you help me in doing the same process for windows (instead Wall Types) ?