Searching for IfcSpace LongName or overlapping IfcSpaces

I have a model where I have a huge amount of overlapping IfcSpaces and need to select groups of spaces based upon LongName or even better, selecting overlapping Spaces (where only the spaces with smallest volume is selected). Preferable I would like to do this with a Python script in Blender but using IFC selector would also work and I wonder if somebody could help me out?

Comments

  • ifcopenshell.util.selector.filter_elements(model, "IfcSpace, LongName=/some regex.*/")

    For checking overlapping spaces, you can use a geometry tree and query spaces using another space element: https://blenderbim.org/docs-python/ifcopenshell-python/geometry_tree.html

  • I ended up using the example from https://wiki.osarch.org/index.php?title=IfcOpenShell_code_examples to select all IfcSpaces with the letters "HB" in LongName but I wonder if somebody could help me to figure out how to make make these objects selected in Blender.

    import bpy
    from ifcopenshell.util.selector import Selector
    from blenderbim.bim.ifc import IfcStore
    ifc = IfcStore.get_file()
    selector = Selector()
    spaces = selector.parse(ifc, '.IfcSpace[LongName *= "HB"]')
    
  • import ifcopenshell.util.selector
    import blenderbim.tool as tool
    
    elements = ifcopenshell.util.selector.filter_elements(model, "IfcSpace, LongName=/.*HB.*/")
    for element in elements:
        obj = tool.Ifc.get_object(element)
        if obj:
            obj.select_set(True)
    
  • Wow, that was fast.
    I got AttributeError: module 'ifcopenshell.util.selector' has no attribute 'filter_elements' but this code worked fine based on your example

    import bpy
    from ifcopenshell.util.selector import Selector
    from blenderbim.bim.ifc import IfcStore
    import blenderbim.tool as tool
    ifc = IfcStore.get_file()
    selector = Selector()
    spaces = selector.parse(ifc, '.IfcSpace[LongName *= "HB"]')
    for space in spaces:
        obj = tool.Ifc.get_object(space)
        if obj:
            obj.select_set(True)
    
  • You might be using an outdated version. The filter_elements function was added recently and is recommended to be used in lieu of the older selector.

  • Thanks, you are releasing new versions faster then I can install.

  • Welcome to alpha software :)

  • There are still way to many spaces selected so I wonder if it would be possible to limit the selection in this script to a certain category in PsetSpaceCommon and storey it belongs to? In this example "Office" and "10B".

Sign In or Register to comment.