-
-
Notifications
You must be signed in to change notification settings - Fork 845
Closed
Labels
Description
Hello!
I am creating a simple house using ifcopenshell-python. Below is a part of my script. Everything is okay in OpenIFCViewer but I can not load the IFC in IFCLoader or online ifc viewers. The problem is when I have 4 walls I can load IFC in IFCLoader but when I add just one more element, either wall or door or window etc, then I get memory access out of bounds and when I remove that 5th element everything is fine again. Am I missing something?
def create_ifc_wall(model, body, wall_info, wall_point_left, wall_point_right, storey, wall_id):
wall = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWall" , name=str(wall_id))
representation_wall = ifcopenshell.api.geometry.create_2pt_wall(model, element=wall, context=body, p1=(wall_point_left[0], wall_point_left[1]), p2=(wall_point_right[0], wall_point_right[1]), elevation=0, height=float(wall_info[0]), thickness=0.02)
ifcopenshell.api.geometry.assign_representation(model, product=wall, representation=representation_wall)
ifcopenshell.api.spatial.assign_container(model, products=[wall], relating_structure=storey)
project = ifcopenshell.api.root.create_entity(model, ifc_class="IfcProject")
site = ifcopenshell.api.root.create_entity(model, ifc_class="IfcSite")
building = ifcopenshell.api.root.create_entity(model, ifc_class="IfcBuilding")
storey = ifcopenshell.api.root.create_entity(model, ifc_class="IfcBuildingStorey")
context = ifcopenshell.api.context.add_context(model, context_type="Model")
body = ifcopenshell.api.context.add_context(model, context_type="Model",
context_identifier="Body", target_view="MODEL_VIEW", parent=context)
ifcopenshell.api.aggregate.assign_object(model, products=[site], relating_object=project)
ifcopenshell.api.aggregate.assign_object(model, products=[building], relating_object=site)
ifcopenshell.api.aggregate.assign_object(model, products=[storey], relating_object=building)
# Create walls
for wall in data['walls']:
wall_info = [wall['height'], wall['width']]
create_ifc_wall(model, body, wall_info, wall['leftmost_point'], wall['rightmost_point'], storey, wall['id'])