Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Returning non intersecting elements with BoundingBoxIntersectsFilter

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
Anonymous
1342 Views, 4 Replies

Returning non intersecting elements with BoundingBoxIntersectsFilter

Anonymous
Not applicable

Greetings,

Im having a problem with the BoundingBoxIntersectsFilter returning elements of which do not appear to intersect with the BoundingBox. Using a BoundingBoxIntersectsFilter from BoundingBox created from endpoints 0 and 1 from conduit A below, always returns intersecting with conduit B shown below.

 

In this case, I am using conduit.Location.Curve.GetEndpoint() to get point 0 and 1 from conduit A.  Then I create an Outline from  each of those points like so, Outline(point0, point0), and Outline(point1, point1) 

 

After running the FilteredElementCollector i receive the expected elements in addition to the unexpected conduit B.

 

I resorted to looping through all of the elements returned and using conduitPoint0or1.DistanceTo(returned elements point) and then removing any from the list that are more than x distance and this conduit B always comes up as intersecting.  No matter how low i make the distance, the FilteredElementCollector will return nothing, except this one conduit B.

 

Any help would be stellar. I will attach my code if that helps some with context.

 

Thanks so much.

 

 

msexton2BR6D_0-1618882052790.png

 

import System
from System import Array
from System.Collections.Generic import *

view = doc.ActiveView
#get all conduit and electrical fixtures in given view
cat_list = [BuiltInCategory.OST_Conduit,BuiltInCategory.OST_ElectricalFixtures,BuiltInCategory.OST_ElectricalEquipment,BuiltInCategory.OST_ConduitFitting]
typed_list = List[BuiltInCategory](cat_list)
filter = ElementMulticategoryFilter(typed_list)
assemblyel = FilteredElementCollector(doc,view.Id).WherePasses(filter).ToElements()
assemblyids = FilteredElementCollector(doc,view.Id).ToElementIds()

cpointlist = []

try:
  for i in assemblyel:
    if i.Category.Name == 'Conduits':
      cpointlist.append(i.Location.Curve.GetEndPoint(0))
      cpointlist.append(i.Location.Curve.GetEndPoint(1))
    else:
        continue
except:
  print('error error error')

def gcinter(points):
    ac = []
    for p in points:
        ol = Outline(p,p)
        bbfilter = BoundingBoxIntersectsFilter(ol)
        bbfilter.Tolerance = 0.125
        collector = FilteredElementCollector(doc).WherePasses(filter)
        ids = [doc.ActiveView.Id]
        ids.extend(assemblyids)
        id = List[ElementId](ids)
        intersects = collector.Excluding(id).WherePasses(bbfilter).ToElements()
        intersects = [doc.GetElement(x.AssemblyInstanceId).Name for x in intersects]
        if len(intersects) != 0: ac.append([p,intersects])
    return ac

 

 

0 Likes

Returning non intersecting elements with BoundingBoxIntersectsFilter

Greetings,

Im having a problem with the BoundingBoxIntersectsFilter returning elements of which do not appear to intersect with the BoundingBox. Using a BoundingBoxIntersectsFilter from BoundingBox created from endpoints 0 and 1 from conduit A below, always returns intersecting with conduit B shown below.

 

In this case, I am using conduit.Location.Curve.GetEndpoint() to get point 0 and 1 from conduit A.  Then I create an Outline from  each of those points like so, Outline(point0, point0), and Outline(point1, point1) 

 

After running the FilteredElementCollector i receive the expected elements in addition to the unexpected conduit B.

 

I resorted to looping through all of the elements returned and using conduitPoint0or1.DistanceTo(returned elements point) and then removing any from the list that are more than x distance and this conduit B always comes up as intersecting.  No matter how low i make the distance, the FilteredElementCollector will return nothing, except this one conduit B.

 

Any help would be stellar. I will attach my code if that helps some with context.

 

Thanks so much.

 

 

msexton2BR6D_0-1618882052790.png

 

import System
from System import Array
from System.Collections.Generic import *

view = doc.ActiveView
#get all conduit and electrical fixtures in given view
cat_list = [BuiltInCategory.OST_Conduit,BuiltInCategory.OST_ElectricalFixtures,BuiltInCategory.OST_ElectricalEquipment,BuiltInCategory.OST_ConduitFitting]
typed_list = List[BuiltInCategory](cat_list)
filter = ElementMulticategoryFilter(typed_list)
assemblyel = FilteredElementCollector(doc,view.Id).WherePasses(filter).ToElements()
assemblyids = FilteredElementCollector(doc,view.Id).ToElementIds()

cpointlist = []

try:
  for i in assemblyel:
    if i.Category.Name == 'Conduits':
      cpointlist.append(i.Location.Curve.GetEndPoint(0))
      cpointlist.append(i.Location.Curve.GetEndPoint(1))
    else:
        continue
except:
  print('error error error')

def gcinter(points):
    ac = []
    for p in points:
        ol = Outline(p,p)
        bbfilter = BoundingBoxIntersectsFilter(ol)
        bbfilter.Tolerance = 0.125
        collector = FilteredElementCollector(doc).WherePasses(filter)
        ids = [doc.ActiveView.Id]
        ids.extend(assemblyids)
        id = List[ElementId](ids)
        intersects = collector.Excluding(id).WherePasses(bbfilter).ToElements()
        intersects = [doc.GetElement(x.AssemblyInstanceId).Name for x in intersects]
        if len(intersects) != 0: ac.append([p,intersects])
    return ac

 

 

Labels (1)
4 REPLIES 4
Message 2 of 5
1240904365
in reply to: Anonymous

1240904365
Enthusiast
Enthusiast
Accepted solution

There is one caveat to the use of BoundingBoxIntersectsFilter:微信图片_20210420175758.png

in this case you will filter the unwanted elements

There is one caveat to the use of BoundingBoxIntersectsFilter:微信图片_20210420175758.png

in this case you will filter the unwanted elements

Message 3 of 5
RPTHOMAS108
in reply to: Anonymous

RPTHOMAS108
Mentor
Mentor
Accepted solution

Yes as @1240904365 noted the outline is parallel to model coordinate system and not the conduit.

 

In your case although the outline you have constructed is in effect a vertical line this is being checked again the bounding box of B as noted below:

 

210420.png

 

After roughly checking for intersections with this quick filter you can then use other means such as ElementIntersectsElementFilter or ElementIntersectsSolidFilter (slow filters).

 

This limits the amount of elements you have to compare using a slow filter.

Yes as @1240904365 noted the outline is parallel to model coordinate system and not the conduit.

 

In your case although the outline you have constructed is in effect a vertical line this is being checked again the bounding box of B as noted below:

 

210420.png

 

After roughly checking for intersections with this quick filter you can then use other means such as ElementIntersectsElementFilter or ElementIntersectsSolidFilter (slow filters).

 

This limits the amount of elements you have to compare using a slow filter.

Message 4 of 5
Anonymous
in reply to: Anonymous

Anonymous
Not applicable

Thanks for the answer, and extended explanation.   Just to clarify, the BoundingBoxIntersectsFilter filters for intersection of a specified Outline with other elements BoundingBox or element geometry?

0 Likes

Thanks for the answer, and extended explanation.   Just to clarify, the BoundingBoxIntersectsFilter filters for intersection of a specified Outline with other elements BoundingBox or element geometry?

Message 5 of 5
3dimdev
in reply to: Anonymous

3dimdev
Enthusiast
Enthusiast
The BoundingBoxIntersectsFilter checks for intersections of other element's bounding boxes, not geometry. This allows it to be a quick filter.
3rd Dimension Developer
YouTube.com/@3DimDev

The BoundingBoxIntersectsFilter checks for intersections of other element's bounding boxes, not geometry. This allows it to be a quick filter.
3rd Dimension Developer
YouTube.com/@3DimDev

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report