Hello,
i want to filter al my structural elements, floors, walls, slabs, beams,…
so how can i do that well
my code works partly
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *
clr.AddReference('System')
from System.Collections.Generic import List
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
collectorWalls = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Walls)
placedWalls = collectorWalls.WhereElementIsNotElementType().ToElements()
collectorColumns = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_StructuralColumns)
placedColumns = collectorColumns.WhereElementIsNotElementType().ToElements()
collectorFloors = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Floors)
placedFloors = collectorColumns.WhereElementIsNotElementType().ToElements()
staticFloors = []
for i in UnwrapElement(placedFloors):
if i.get_Parameter(BuiltInParameter.FLOOR_PARAM_IS_STRUCTURAL).AsBoolean() == True:
staticFloors.append(i)
else:
pass
OUT = placedWalls,placedColumns, placedFloors, staticFloors

KR
Andreas
Parameters don’t have an AsBoolean()
method. Use AsInteger()
instead.
1 Like
@Nick_Boyts
for any reason it still remains as an error
is there any other error? or a better way to handle it?
You still have an issue with at least one element not having that parameter, which is why it’s returning NoneType
. It looks like you copied the line from placedColumns
and didn’t change it for floors, so you’re using the collector for columns in line 33.
@Nick_Boyts ,
collectorFloors = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Floors)
placedFloors = collectorFloors.WhereElementIsNotElementType().ToElements()
staticFloors = []
for i in UnwrapElement(placedFloors):
if i.get_Parameter(BuiltInParameter.FLOOR_PARAM_IS_STRUCTURAL).AsInteger() == 1:
staticFloors.append(i)
else:
pass
OUT = staticFloors
it is missing the step to collect the elements ?
or do i precheck my elements and based on that collect my load beariing elements?
collectorFloors = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Floors)
placedFloors = collectorFloors.WhereElementIsNotElementType().ToElements()
staticFloors = []
for i in UnwrapElement(placedFloors):
p = i.get_Parameter(BuiltInParameter.FLOOR_PARAM_IS_STRUCTURAL).AsInteger()
if p == 1:
staticFloors.append(i)
else:
pass
OUT = staticFloors
Your initial code was using the wrong collector. It looks like you’ve since fixed it? Are you still getting the same NoneType
error?
1 Like
So first I’d just return my list of floors to make sure that’s giving me the elements I expect. I’m not aware of a scenario where a floor doesn’t have that parameter but it may exist. In that case you would have to check for the parameter before getting the value.
1 Like