@alfasst said:
I was trying to find connected spaces using IfcOpenShell. But I couldn't find a way to extract the spaces connected by a stair. I am using the FZK Haus as the sample file. I have tried the geometry tree approach and was able to find the bottom space connected but not the top space.
Hi! Can you please show the code that didn't worked?
Just tested the code below with bounding box selection:
import ifcopenshell
ifc_file = ifcopenshell.open(r"AC20-FZK-Haus.ifc")
import multiprocessing
import ifcopenshell.geom
from pprint import pprint
def check_intersections(ifc_file):
tree = ifcopenshell.geom.tree()
settings = ifcopenshell.geom.settings()
iterator = ifcopenshell.geom.iterator(
settings, ifc_file, multiprocessing.cpu_count()
)
if iterator.initialize():
while True:
tree.add_element(iterator.get_native())
if not iterator.next():
break
element = ifc_file.by_type("IfcStair")[0]
pprint(tree.select_box(element))
[#59290=IfcSlab('2RGlQk4xH47RHK93zcTzUL',#12,'Slab-033',$,$,#59253,#59286,'DA0A17AC-B773-47AC-99-C5-D390C73AD5CC',.FLOOR.),
#33774=IfcSpace('0Lt8gR_E9ESeGH5uY_g9e9',#12,'5',$,$,#33683,#33769,'Wohnen',.ELEMENT.,$,$),
#59365=IfcOpeningElement('16PF6khT5_p$Z03P73inyv',#12,'Slab Opening',$,$,#59331,#59361,$,$),
#39432=IfcMember('1qMEiq1Qz6guq8g1GCODiJ',#12,'Sparren-34',$,$,#39415,#39428,'3A999AF6-1C12-413A-89-B2-BF4A3CAEAD63',$),
#39186=IfcMember('1NBDw_i_jD$u7IjvwmbPmx',#12,'Sparren-32',$,$,#39169,#39182,'62D6313A-B4FB-45BF-B3-97-10D01124A4F9',$),
#39309=IfcMember('2DH$OLoObDkAtwqVzNdUnS',#12,'Sparren-33',$,$,#39292,#39305,'E4FF91FA-3AE7-4591-8D-5F-61E57F7BA5DE',$),
#14502=IfcStair('38a9vdh9bF5Qg28GWyHhlr',#12,'Wendeltreppe',$,$,#502,#14498,'79A67A01-C95B-4209-86-9A-74983B65305C',$),
#59753=IfcSlab('2IxUUNUVPB6Ob$eicCfP2N',#12,'Dach-2',$,$,#59716,#59749,'BD6D9414-37DF-40A8-88-40-301A32A9A5B5',.ROOF.),
#49831=IfcRailing('0o5vgCKyTBzO5$QJcI2YDP',#12,'',$,$,#40768,#49827,'00000000-0000-0000-00-00-000000000000',.HANDRAIL.),
#76214=IfcSpace('2dQFggKBb1fOc1CqZDIDlx',#12,'7',$,$,#76123,#76209,'Galerie',.ELEMENT.,$,$)]
check_intersections(ifc_file)