Hallo community,
maybe someone knows why the filter doesnt collect the elements within the boundingbox… ?
If I try to retrieve the elements without considering the boundingbox, it works out. Only when I try to retrieve the elements within the boundingbox, there is no output.
Revit view:

Code:
_linkDoc = IN[0]
_category = IN[1][0]
activeView = UnwrapElement(IN[2])
bbxMin = activeView.GetSectionBox().Min
bbxMax = activeView.GetSectionBox().Max
ol = Outline(bbxMin,bbxMax)
try:
errorReport = None
filter = ElementCategoryFilter(System.Enum.ToObject(BuiltInCategory, _category.Id))
bbfilter = BoundingBoxIntersectsFilter(ol)
andfilter = LogicalAndFilter(filter,bbfilter)
result = FilteredElementCollector(_linkDoc).WherePasses(andfilter).WhereElementIsNotElementType().ToElements()
except:
# if error accurs anywhere in the process catch it
import traceback
errorReport = traceback.format_exc()
#Assign your output to the OUT variable
if errorReport == None:
OUT = result
else:
OUT = errorReport
Try to get your code working without a try loop first. Otherwise you can’t see what error you’re getting.
I also tried out without the try / except and the output is again empty:
lnkDoc = IN[0]
category =UnwrapElement(IN[1])[0]
activeView = UnwrapElement(IN[2])
bbxMin = activeView.GetSectionBox().Min
bbxMax = activeView.GetSectionBox().Max
ol = Outline(bbxMin,bbxMax)
#category filter
catfilter = [ElementCategoryFilter(System.Enum.ToObject(BuiltInCategory, int(str(category.Id))))]
catfilterlist = List[ElementFilter](catfilter)
filter = LogicalOrFilter(catfilter)
#combining boundingbox and category filters
bbfilter = BoundingBoxIsInsideFilter(ol)
andfilter = LogicalAndFilter(filter,bbfilter)
#collecting elements
coll = FilteredElementCollector(lnkDoc).WherePasses(andfilter).WhereElementIsNotElementType().ToElements()
OUT = coll
oh, i found out the reason
lnkDoc = IN[0]
category =UnwrapElement(IN[1])[0]
activeView = UnwrapElement(IN[2])
bbx = activeView.GetSectionBox()
bbx.Max = XYZ(500,500,500)
bbx.Min = XYZ(-500,-500,-500)
#bbxMin = activeView.GetSectionBox().Min
#bbxMax = activeView.GetSectionBox().Max
bbxMin = bbx.Min
bbxMax = bbx.Max
ol = Outline(bbxMin,bbxMax)
I just redefined the boundingBox manually by giving other values and somehow the elements are retrieved, it means that bbx = activeView.GetSectionBox is not working out properly…
any ideas why?
It’s hard to say without seeing any of your inputs, but I would guess the view does not have a section box assigned or you’re not handling the view properly.