ifcopenshell: find connecting faces / vertices without using ConnectedTo
Heyhey,
I'm still fairly new to ifcopenshell and I'm hoping that some more experienced users can help me find the most efficient way to solve my problem :)
Here is the problem: I need to determine the connections between walls and I have to deal with a bunch of IFC files, in which the ifc_element.ConnectedTo
property is almost always empty. So my guess is that in order to find connecting faces or vertices I have to use the geometries to solve my problem. So far I have identified different strategies.
1. just find common vertices between two walls, however this does not solve all my problems, since I also have T connections where there will be no common vertices
2. transform the geometries to the 2D plane and use a third party geometry library to find an intersection between the polygons (2D should probably solve most of my cases for now and I should be able to transform it back to 3D)
3. try my luck with settings.USE_PYTHON_OPENCASCADE
, but so far I have only scratched the surface of OCC and I would need several hours to find out if it is able to do the job.
Do you have any hints for me, what might be the most promising approach?
Comments
If the semantics are incomplete, your best bet is to do geometric analysis as you've mentioned. One way of doing this is by using a geometry tree: https://blenderbim.org/docs-python/ifcopenshell-python/geometry_tree.html
Another method might be to use the voxelisation toolkit https://github.com/opensourceBIM/voxelization_toolkit
Thanks a lot! The geometry tree helps me get the adjacent elements.
Now what I need to do next is find out how to determine the connection geometry and for that I will probably have to dive into geometry libraries for intersections in 2D or 3D space. Can OCC give me the intersection of two walls?
OCC can give it to you, yes. Have you got a picture describing what type of intersection you're after?
Basically it's very similar to
IfcRelConnectsPathElement
and theCurveOnRelatedElement
/CurveOnRelatingElement
in this picture: https://standards.buildingsmart.org/IFC/RELEASE/IFC4/ADD2/HTML/schema/ifcsharedbldgelements/lexical/ifcrelconnectspathelements.htmIn our case it's much simpler though, we usually have rectangular connections, so it would be sufficient to know which vertices from wall A are touching wall B.
@xwoe well walls are always along the +X local axis, so you can use
get_vertices
to get local vertices, find min X and max X (for ATSTART and ATEND) andget_shape_matrix
to convert minX and maxX to global coords, then those global coords can be fed into the geometry tree to query what it's touching.That's an amazing idea, thank you so much @Moult !
I guess finding the edges of the wall as you described and with
elements = tree.select((global_x, global_y, global_z))
I should get what I want.Cheers, one more suggestion is to disable openings - it'll be significantly faster and serve your purposes equally well: https://blenderbim.org/docs-python/ifcopenshell/geometry_settings.html#disable-opening-subtractions