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; }
Solved! Go to Solution.
Solved by j.tepelmann. Go to Solution.
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
Thank you very much for your reply! I will create a test case and submit it here.
Kind Regards,
Jan
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! 🙂
Dear Jan,
Thank oyu very much for sharing this valuable information!
My kudos.
I now published this thread for posterity:
Cheers,
Jeremy