ElementIntersectSolidFilter strange behaviour

ElementIntersectSolidFilter strange behaviour

andres.buitragoY4KG4
Contributor Contributor
653 Views
7 Replies
Message 1 of 8

ElementIntersectSolidFilter strange behaviour

andres.buitragoY4KG4
Contributor
Contributor

Hi everyone,

 

 I am trying to get the thickness of the walls that a Window cuts through. I can get easily the thickness of the wall that the window is hosted, however there is an extra wall (insulation) placed outside of the host wall which I must also know the thickness of. Therefore I thought on using the ElementIntersectSolidFilter with a solid geometry from the window:

Here is my code:

 

 

var windowGeometry = window.get_Geometry(new Options() {
    DetailLevel = ViewDetailLevel.Fine
});
var w = windowGeometry.First() as GeometryInstance;
var instanceGeometry = w.GetInstanceGeometry(window.GetTotalTransform());

// get solid for intersection
Solid fensterbankSolid = null;
foreach(var geo in instanceGeometry) {
    var graphicsId = (geo as GeometryObject).GraphicsStyleId;
    var graphicStyle = linkDoc.GetElement(graphicsId).Cast < GraphicsStyle > ();
    // The element with the graphicStype should cut through both insulation and wall.
    if (graphicStyle?.Name.Contains("Fensterbank Aus") ?? false) {
        fensterbankSolid = geo as Solid;
        break;
    }
}

if (fensterbankSolid != null) {
    FilteredElementCollector wallIntersections = new FilteredElementCollector(linkDoc)
        .OfClass(typeof (Wall))
        .WherePasses(new ElementIntersectsSolidFilter(fensterbankSolid as Solid));
    int n = wallIntersections.Count();
    if (n > 0) {
        // I only care about the intersecting walls that have type name "DAE" 
        var insulation = wallIntersections.Where(wall => wall.Name.Contains("DAE")).FirstOrDefault();
        if (insulation != null) {
            Wall insulationWall = insulation as Wall;
            Debug.WriteLine($"Window intersects insulation of: {insulationWall.Width.ToMillimeters()}mm");
            existingWallThickness += insulationWall.Width;
        }
    }
}

 

 

The results of the IntersectionFilter collector are a two 340 mm wall, and a 90 mm insulation wall. But what is expected is to find one 340 mm and one 60 mm insulation wall.

 

andresbuitragoY4KG4_0-1697440194951.png

 

Is the code above the correct way to get the geometry of the window instance?
Is there an easier way to find the intersecting walls to a Window Instance?

 

Thank you

0 Likes
Accepted solutions (1)
654 Views
7 Replies
Replies (7)
Message 2 of 8

andres.buitragoY4KG4
Contributor
Contributor

Furthermore, this are the elements I get as result from the `wallIntersections` collector. Strangely they are not intersecting with the window providing the solid geometry, and second how is it possible that it returns three walls, one of which is perpendicular to the others?

 

andresbuitragoY4KG4_0-1697442746974.png

 

0 Likes
Message 3 of 8

GaryOrrMBI
Collaborator
Collaborator

I'm working on a somewhat similar task and I came to the conclusion that an intersects filter can't work in this type of situation because the opening in the second wall creates an absence of anything to intersect with.

 

I can't speak to why you are getting the walls at 90 degrees from your insert, perhaps the geometry of your window may have nonvisible elements that make the geometry larger than it appears???

 

I ended up having to resort to a triple check type of scenario:

 

1) Check for joined walls (in case that is the method used to cut the opening in any adjoining walls), then equalize the location curve of any joined walls and the insertion point of the window (IE: modify the "z" point of the insert to match the "z" points of the wall curve) then use a curve.Distance test from the curve to the equalized insertion point of the insert to determine if it was within a given range, if it meets my criteria then it is joined at the point of the insert and qualifies as a secondary wall part to be added to the whole.

 

2) Create a dictionary of Revit rectangular wall openings. Collected the Boundry rectangle points and derived a "location" point from them. I then used that derived point as a key and the Boundry element as the value for each dictionary entry. Then, as I located each insert that I was interested in, I would check it's distance (XYZ.DistanceTo) against the dictionary entries, and get the hostwall of any that fit within my desired range.

 

3) Create a dictionary of door, window, and generic model instances that could have been used to create a companion opening in any associated walls and test against their locations (similar to step 2) and get their host wall.

 

And then... a bit of math to generate the total wall width (which also needed to take into account any gap between the primary wall and any associated walls on either side)...

 

It was a real pain, and I didn't have the complication of working through a link.

 

-G

Gary J. Orr
GaryOrrMBI (MBI Companies 2014-Current)
aka (past user names):
Gary_J_Orr (GOMO Stuff 2008-2014);
OrrG (Forum Studio 2005-2008);
Gary J. Orr (LHB Inc 2002-2005);
Orr, Gary J. (Gossen Livingston 1997-2002)
0 Likes
Message 4 of 8

andres.buitragoY4KG4
Contributor
Contributor

Hi Gary,

thanks for the detailed thought process. Its a lot more than I imagined for this task that seems simple but I will try as well.

I didn't think that the window would not intercept because of the opening in the second wall, but it makes sense. Since you mention that, I will also try to "inflate" the bounding box of the window and create a solid from it and see if this gives any intersections. 

Best,

Andres

0 Likes
Message 5 of 8

NGM_AiYo
Advocate
Advocate

I noticed you are doing collision in link document, using lookup, check your RevitLinkInstance's TotalTransform, if it's origin is not at (0,0,0), before you do intersection filter, you need to transform your solid. 

0 Likes
Message 6 of 8

andres.buitragoY4KG4
Contributor
Contributor
Thats right, the im trying to calculate the intersection on the link document. But the solid is coming from another element in the same Linked document. In that case would it be necessary to transform as well?
0 Likes
Message 7 of 8

NGM_AiYo
Advocate
Advocate

In same doc?  not necessary. Maybe you can try to use ElementIntersectsElementFilter instead of solid filter.

0 Likes
Message 8 of 8

andres.buitragoY4KG4
Contributor
Contributor
Accepted solution

I tried ElementIntersectsElementFilter first but it didnt work. probably because the wall I am trying to find is already cut by revit so technically they don't intersect (?). It would be good to find out if this is true, but I solved it by creating a solid from the bounding box of my window, and using that for ElementIntersectSolid filter.

 

0 Likes