Hi,
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':
output.append(w)
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
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
import Autodesk.DesignScript.Geometry as DS
#import Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
import Autodesk.Revit.DB as DB
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
clr.AddReference("System.Core")
clr.ImportExtensions(System.Linq)
walls = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Walls)\
.WhereElementIsNotElementType()\
.Where(lambda w : w.WallType.Kind == WallKind.Basic)
OUT = walls
3 Likes