Filter basic walls with FilteredElementCollector


I am trying to replicate the below code into python to get the basic walls in the mode. However, I can’t figure out how to create a filter to enquire the Wall.WallType.Kind=Basic property?

FilteredElementCollector BasicWallCollector = new FilteredElementCollector(doc).OfClass(typeof(Wall));
            IEnumerable<Wall> BasicWalls = BasicWallCollector.Cast<Wall>().Where(w => w.WallType.Kind == WallKind.Basic);

Could you suggest to me a way of creating the filter here?

walls = FilteredElementCollector(doc).OfClass(Wall).WherePasses(filter).ToElements()

python does not have cast from c#

closest method maybe:

walls = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Walls).WhereElementIsNotElementType().ToElements()

output = []
for w in walls:
	type = doc.GetElement(w.GetTypeId())
	if str(getattr(type, 'Kind')) == 'Basic':
1 Like

if you really want to do a filter then you can check the wall’s volume parameter. Basic wall will has this while curtain wall donesn’t. You can set a filter to check its existance. (CreateHasValueParameterRule)

pvp = ElementId(BuiltInParameter.HOST_VOLUME_COMPUTED)
rule = ParameterFilterRuleFactory.CreateHasValueParameterRule(pvp)
filter = ElementParameterFilter(rule)

walls = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Walls).WherePasses(filter).ToElements()
1 Like

FYI the use of PLINQ remains easily possible with IronPython

import sys
import clr
import System
from Autodesk.DesignScript.Geometry import *
import Autodesk.DesignScript.Geometry as DS

#import Revit API
import Autodesk
from Autodesk.Revit.DB import *
import Autodesk.Revit.DB as DB

import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument


walls = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Walls)\
									.Where(lambda w : w.WallType.Kind == WallKind.Basic)

OUT = walls