BoundingBoxIntersectsFilter problem

Dear Specialists,

I have a problem with the Bounding Box Intersecting Filter.

This is my script:

import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference("RevitServices")
from Autodesk.Revit.DB import Transaction

#load the Documentmanager out of library RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

#load the Current View (with Revit Services)
doc = DocumentManager.Instance.CurrentDBDocument
TransactionManager.Instance.EnsureInTransaction(doc)

#receive rooms
ROOMS_PRO = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Rooms).ToElements()
ROOMS_PRO_DB = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Rooms)
SCOPE_BOX = IN[0]

#rooms in scope box
ROOMS_SC = []
for R_ZOEKEN in SCOPE_BOX:
    bb = R_ZOEKEN.BoundingBox
    RVT = bb.ToRevitType()
    outline = Outline(RVT.Min, RVT.Max)
    filter = BoundingBoxIntersectsFilter(outline)
    collector = ROOMS_PRO_DB.WherePasses(filter).ToElements()
    ROOMS_SC.append(collector)

OUT = ROOMS_SC

The problem is that the script didnt find the second rooms, the middle of the rooms are in the scope boxes. The second one rooms cannot be find.

Could anyone help me?


Are you sure there are rooms intersecting with the second scope box?

I’m not sure how Dynamo defines the bounding box of a scope box. It would be safer to use the Revit API with Element.get_BoundingBox(None) (after passing through UnwrapElement()) which uses the model space dimensions of the scope box.

A few notes on the code. In Python ‘convention’ ALL_CAPS is normally used to define constants. Be careful of the Python built in functions - like filter as you have redefined this over the top of the pre-loaded function

You could simplify the code - something like this

import clr

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

clr.AddReference("RevitServices")
from RevitServices.Persistence import DocumentManager

doc = DocumentManager.Instance.CurrentDBDocument

if isinstance(IN[0], list):
    scope_boxes = UnwrapElement(IN[0])
else:
    scope_boxes = [UnwrapElement(IN[0])]

room_fec = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Rooms)

rooms = []

for scope_box in scope_boxes:
    bb = scope_box.get_BoundingBox(None) # Model not view
    outline = Outline(bb.Min, bb.Max)
    bbif = BoundingBoxIntersectsFilter(outline)
    rooms.append(room_fec.WherePasses(bbif).ToElements())

OUT = rooms