Better option to make openings in walls / facade

Hi there,
I am using IfcOpenShell to create an IFC model.
Everything works fine but I realized that making openings is really slowing my code down, so a medium size model containing multiple buildings takes up to 6 minutes to generate.

My code for making openings looks like this :

for aperture_outline in aperture_outlines:
    z_aperture_outline = aperture_outline['openingOutline']['data']['pts'][0]['data']['z'] 
    height_above_slab = z_aperture_outline - z_facade
    if abs(z_pos) > 0.01:
        height_above_slab += z_pos
    opening = make_opening(ifcfile, sb, body, ifc_story, facade, aperture_outline, height=0, z_pos=height_above_slab)
def make_opening(ifcfile, sb, body, storey, wall, aperture_outline, height=0, z_pos=0.0):
    opening = ifcopenshell.api.run("root.create_entity", ifcfile, ifc_class="IfcOpeningElement", name="Opening")
    points = aperture_outline['openingOutline']['data']['pts']
    height = aperture_outline['height']
    pts = convert_points(points)
    profile = sb.polyline(pts)
    extruded_solid = sb.extrude(profile, magnitude=height, position=mathutils.Vector((0.0, 0.0, z_pos)), extrusion_vector=mathutils.Vector((0.0, 0.0, 1.0)))
    representation = sb.get_representation(body, extruded_solid)

    ifcopenshell.api.run("geometry.assign_representation", ifcfile, product=opening, representation=representation)
    ifcopenshell.api.run("spatial.assign_container", ifcfile, product=opening, relating_structure=storey)
    ifcopenshell.api.run("geometry.edit_object_placement", ifcfile, product=opening)
    ifcopenshell.api.run("void.add_opening", ifcfile, opening=opening, element=wall)

    return opening

Does someone know any possibility to fix this?
It would help a lot!!
Thank you

Comments

  • Hi! Any ideas what line is taking the most time?

  • I guess it's adding the openings:

    ifcopenshell.api.run("void.add_opening", ifcfile, opening=opening, element=wall)
    

    Beacuse the rest is quite similar to what I do for making the facades and that's reasonably fast

    def make_facade(ifcfile, sb, body, storey, facade, height=0, slab_thickness=0.2, z_pos=0.0):
        facade_element = ifcopenshell.api.run("root.create_entity", ifcfile, ifc_class="IfcWall", name="Facade")
        outline = facade['data']['outline']
        points = outline['data']['pts']
        pts = convert_points(points)
        profile = sb.polyline(pts)
        extruded_solid = sb.extrude(profile, magnitude=height + slab_thickness, position=mathutils.Vector((0.0, 0.0, z_pos)), extrusion_vector=mathutils.Vector((0.0, 0.0, 1.0)))
        representation = sb.get_representation(body, extruded_solid)
        ifcopenshell.api.run("geometry.assign_representation", ifcfile, product=facade_element, representation=representation)
        ifcopenshell.api.run("spatial.assign_container", ifcfile, relating_structure=storey, product=facade_element)
        ifcopenshell.api.run("geometry.edit_object_placement", ifcfile, product=facade_element)
        color = ColorRGB(*convert_hex_to_rgb(get_render_color("facade")))
        create_style(ifcfile, representation, color)
    
        return facade_element
    
  • Can you try to profile the void.add_opening on what part taking the most time in your case? Or share some .ifc and code example to reproduce this?

    jemanik
  • I profiled it and apparently it is not the the conversion or making the openings.
    My code is running on a server and it seems what is taking a lot of time is reading the JSON request data and sending the IFC file back.
    That it is much faster without the openings must be just because the huge amount of openings
    Thanks @Andrej730

Sign In or Register to comment.