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: 

BoundingBoxIntersectsFilter not working

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
j.tepelmann
1961 Views, 6 Replies

BoundingBoxIntersectsFilter not working

Hi,

 

I'm a programmer at Inreal Technologies and were developing Enscape 3D, a rendering plugin for Revit.

Currently we are working on speeding up the switching between two 3D views. Right now we just recreate the scene to render but this is obviously very slow.

So I came up with the following code to find out which elements were added, removed and modified when you switch from one view (the start view) to another view (the target view). The idea behind the code is, that we want to know all elements which got cut by the start view's section box or will get cut by the target view section box. For those elements the geometry has to be updated.

The problem now is that it misses a ceiling in the Advanced Sample Project when I switch from the default 3D view to "03 - Floor Public - Day Rendering" view. See attached screenshot. What am I missing? I have to say that I'm relatively new to the filtering API so any help is appreciated.

 

Thanks in advance

 

public static DiffUpdateElementIds Calculate(View3D startView, View3D targetView)
{
     var diffElements = new DiffUpdateElementIds();

     //... here added and removed elements are calculated (with exclude filter). This works just fine 

     if (startView.IsSectionBoxActive || targetView.IsSectionBoxActive)
     {
          ElementFilter intersectFilterStart = null;
          ElementFilter intersectFilterTarget = null;
          if (startView.IsSectionBoxActive)
          {
               Logger.getINSTANCE(Logger.LogFile.EnscapeRevitPlugin).info("start View has SectionBox");
               intersectFilterStart = new BoundingBoxIntersectsFilter(new Outline(startView.GetSectionBox().Min, startView.GetSectionBox().Max));
          }
          if (targetView.IsSectionBoxActive)
          {
               Logger.getINSTANCE(Logger.LogFile.EnscapeRevitPlugin).info("target View has SectionBox");
               intersectFilterTarget = new BoundingBoxIntersectsFilter(new Outline(targetView.GetSectionBox().Min, targetView.GetSectionBox().Max));
          }
                
          ElementFilter intersectFilter;
          if (intersectFilterStart != null && intersectFilterTarget == null)
          {
               intersectFilter = intersectFilterStart;
          }
          else if (intersectFilterStart == null && intersectFilterTarget != null)
          {
               intersectFilter = intersectFilterTarget;
          }
          else
          {
               intersectFilter = new LogicalOrFilter(intersectFilterStart, intersectFilterTarget);
          }

          var cutElementsStartView = new FilteredElementCollector(startView.Document, startView.Id).WherePasses(intersectFilter);
          var cutElementsTargetView = new FilteredElementCollector(targetView.Document, targetView.Id).WherePasses(intersectFilter);
          diffElements.ModifiedElements = cutElementsStartView.UnionWith(cutElementsTargetView).ToElementIds();
     }
     return diffElements;
}

 

 

www.enscape3d.com
E j.tepelmann@inreal-tech.com
6 REPLIES 6
Message 2 of 7
jeremytammik
in reply to: j.tepelmann

Please submit a minimal reproducible test case for us to look at:

 

http://thebuildingcoder.typepad.com/blog/about-the-author.html#1b

 

We may need to pass it on to the development team for further analysis.

 

Thank you!

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 7
j.tepelmann
in reply to: jeremytammik

Thank you very much for your reply! I will create a test case and submit it here.

 

Kind Regards,

 

Jan

www.enscape3d.com
E j.tepelmann@inreal-tech.com
Message 4 of 7
j.tepelmann
in reply to: j.tepelmann

I could find the problem now by myself. Maybe it’s useful for someone who has the same problem:

 

if (startView.IsSectionBoxActive)
{
    Transform t = startView.GetSectionBox().Transform;
    Outline o = new Outline(t.OfPoint(startView.GetSectionBox().Min), t.OfPoint(startView.GetSectionBox().Max));
    intersectFilterStart = new BoundingBoxIntersectsFilter(o);
}
if (targetView.IsSectionBoxActive)
{
    Transform t = targetView.GetSectionBox().Transform;
    Outline o = new Outline(t.OfPoint(targetView.GetSectionBox().Min), t.OfPoint(targetView.GetSectionBox().Max));
    intersectFilterTarget = new BoundingBoxIntersectsFilter(o);
}

The code I was missing is highlighted. So I was just missing that the section box can have a transformation. I thought the box is always defined in world space, but that's not true. Sometimes it is not and then the old code did not work. So hopefully this helps someone who has the same issue.

Now everything is working and the switch between two 3D views is now much much faster then before. Great! 🙂

www.enscape3d.com
E j.tepelmann@inreal-tech.com
Message 5 of 7
Scott_Wilson
in reply to: j.tepelmann

When using the bounding box filters I usuallycombine the BoundingBoxIntersectionFilter with a BoundingBoxContainsFilter using a LogicalOrFilter to make sure to get elements that are entirely within the box, not just those that cross it.
Message 6 of 7
Scott_Wilson
in reply to: j.tepelmann

Nevermind. Just realised that you are only interested in the crossing elements. I really should read posts more carefully before replying...
Message 7 of 7
jeremytammik
in reply to: j.tepelmann

Dear Jan,

 

Thank oyu very much for sharing this valuable information!

 

My kudos.

 

I now published this thread for posterity:

 

http://thebuildingcoder.typepad.com/blog/2016/03/api-sdk-and-view-section-box-element-intersection-f...

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community