BoundingBoxIsInsideFilter (quick filter)

Hello everyone,
I am trying to filter for viewports on a specific sheet that are outside of a defined outline (such as anything floating outside of the title block). I am trying to use this combination of filters but my result is showing me all the viewports on the sheet and is ignoring the outline.
What am I doing wrong?
Thank you!

import Autodesk
from Autodesk.Revit import DB
from Autodesk.Revit.DB import Transaction, XYZ, Outline

doc = revit.ActiveUIDocument.Document
view = doc.ActiveView

p1 = XYZ(0, 0, 0)
p2 = XYZ(3.5, 2.5, 0)

#Set outline
outline1 = Outline(p1, p2)

#create quickfilter with outline,False to select items outside the outline
outlineout = DB.BoundingBoxIsInsideFilter(outline1, True)

#create quickfilter for current view only
eovf = DB.ElementOwnerViewFilter(view.Id)

#create logical filter AND
notinoutline = DB.LogicalAndFilter(eovf, outlineout)

#filter for viewports only
outsidecol = DB.FilteredElementCollector(doc).WherePasses(notinoutline)

vports = outsidecol.OfCategory(DB.BuiltInCategory.OST_Viewports).ToElements()

for ins in vports:
print(“out:”, ins, ins.Name, ins.GetBoxCenter())

not on the subject but code formatting in discourse works with ``` at the beginning and en of you block of code

import blah
for i in listing:
   do this
print 
1 Like

@Jean-Marc I don’t know what happened, when I copy/pasted my code it messed up the formatting. I have it correctly in the actual script… Thanks!

What I meant was pasting on a new line then pasting you code block then adding on a new line will auto format your code block

test post

import Autodesk
from Autodesk.Revit import DB
from Autodesk.Revit.DB import Transaction, XYZ, Outline


doc = __revit__.ActiveUIDocument.Document
view = doc.ActiveView

p1 = XYZ(0, 0, 0)
p2 = XYZ(3.5, 2.5, 0)

#Set outline
outline1 = Outline(p1, p2)

#create quickfilter with outline,False to select items outside the outline
outlineout = DB.BoundingBoxIsInsideFilter(outline1, True)

#create quickfilter for current view only
eovf = DB.ElementOwnerViewFilter(view.Id)

#create logical filter AND
notinoutline = DB.LogicalAndFilter(eovf, outlineout)

#filter for viewports only
outsidecol = DB.FilteredElementCollector(doc).WherePasses(notinoutline)

vports = outsidecol.OfCategory(DB.BuiltInCategory.OST_Viewports).ToElements()

for ins in vports:
    print("out:", ins, ins.Name, ins.GetBoxCenter())
1 Like

thank you @Jean-Marc I hope I got this right this time… I have to admit… it took me a while to figure it out :sweat_smile:

2 Likes