I need to find an outline for many elements (>100'000 items). Target elements come from a FilteredElementCollector. As usual I'm looking for the fastest possible way.
For now I tried to iterate over all elements to get its BoudingBox.Min and BoudingBox.Max and find out minX, minY, minZ, maxX, maxY, maxZ. It works pretty accurate but takes too much time.
The problem is described above is a part of a bigger one. I need to find all the intersections of ducts, pipes and other curve-based elements from a link model with walls, ceilings, columns, etc. in the general model and then place openings in a intersection.
I tried to use a combination of ElementIntersectElement filter and IntersectSolidAndCurve method to find a part of curve inside element.
First with an ElementIntersectElement I tried to reduce a collection for further use of IntersectSolidAndCurve .IntersectSolidAndCurve takes two argument: solid and curve and have to work in two nested one in the other loops. So, it takes for 54000 walls (after filtering) and 18000 pipes in my case 972'000'000 operation.
With the number of operations 10 ^ 5, the algorithm shows an acceptable time. I decided to reduce the number of elements by dividing the search areas by levels. This works well for high-rise buildings, but still bad for extended low structures. I decided to divide the building by length, but I did not find a method that finds boundaries for several elements (the whole building).
I seem to go in a wrong way. Is there are right way to make it with revit api instrument
To find boundaries we can take advantage of the binary search idea.
The difference from the classic binary search algorithm is there is no an array, and we should find two number instead of a one.
Elements in Geometry space could be presented as a 3-dimensional sorted array of XYZ points.
Revit api provides excellent
Quick Filter:BoundingBoxIntersectsFilterthat takes an instance of anOutlineSo, let’s define an area that includes all the elements for which we want to find the boundaries. For my case, for example 500 meters, and create
minandmaxpoint for the initial outlineBelow is an implementation for one direction, however, you can easily use it for three directions by calling and feeding the result of the previous iteration to the input
The
GetBoundariesmethod returns twoXYZpoints: lower and upper, which change only in the target direction, the other two dimensions remain unchangedProjection is an extention method for vector to determine the length of projection one vector for another