IfcOpenShell - Retrieve building from Element

Hello everyone,
I am working on a script that would scan any given IFC and export quantities to a csv file.
For each wall, I can get its level / ID / Type but I cannot manage to get its building ? Is there any property I am missing or any function ? (couldn't find any inifcopenshell.util.element)

If you have any advice, please let me know ! Thanks

Comments

  • Here's a function that does exactly this: get_parent_building()

    Coenarthur595
  • edited February 2023

    Thank you for your response,
    I copied the function to my script, but I get "None" for every wall in my for loop.
    After a bit of debugging, all I know is that every wall is an "IfcElement", and their parent is "Level 01". Then, the function iterates with "Level 01" as an argument, but this one isn't an "IfcElement" nor any IfcType in the if statement.
    Tried with several IFC, always getting "None".

    If I try this, I only get None too. None of my levels are parented to my Building, is it something common ?
    for storey in model.by_type("IfcBuildingStorey"):
    print(get_parent_building(storey))

    Any advice ?

  • @arthur595 no idea, this function works with my IFC files, but they all have a similar structure. Can you upload an example file where it doesn't work?

  • edited February 2023

    @brunopostle sure, here it is. Very simple, only one Building (unnamed) and one Storey.

    [EDIT]
    Found an IFC which worked. I guess mine wasn't exported correctly from Revit.

  • @arthur595 thanks, the function didn't work with IFC2x3 files (IfcSpatialStructureElement was renamed to IfcSpatialElement in IFC4), I've updated it: get_parent_building()

Sign In or Register to comment.