@aothms it's been definitely very interesting to learn! I'll polish it a bit and publish a Jupyter Notebook, which I think can be also valuable to people learning the high level Python API today.
@Moult for now, here's a snippet of the roof creation, and the current IFC is attached:
roof = ios.root.create_entity(file, ifc_class='IfcRoof', name='Roof', predefined_type='GABLE_ROOF')
ios.spatial.assign_container(file, product=roof, relating_structure=storey)
roof_representation_south = ios.geometry.add_wall_representation(
file, context=body, length=roof_size.x, height=(storey_size.y / 2 + wall_thickness + roof_ledge.y),
thickness=roof_thickness, x_angle=(180 - roof_angle) * np.pi/180
)
roof_representation_north = ifcopenshell.util.element.copy_deep(file, roof_representation_south)
roof_downward_offset = (roof_ledge.y + wall_thickness / 2) * np.tan(roof_angle * np.pi / 180)
south_roof = ios.root.create_entity(file, ifc_class='IfcSlab', name='South roof', predefined_type='ROOF')
ios.geometry.assign_representation(file, product=south_roof, representation=roof_representation_south)
ios.geometry.edit_object_placement(
file, product=south_roof, matrix=placement_matrix(
[-roof_size.x / 2, -roof_ledge.y - wall_thickness / 2, storey_size.z - roof_downward_offset],
z_local=[0., 1., 0.]
)
)
north_roof = ios.root.create_entity(file, ifc_class='IfcSlab', name='North roof', predefined_type='ROOF')
ios.geometry.assign_representation(file, product=north_roof, representation=roof_representation_north)
ios.geometry.edit_object_placement(
file, product=north_roof, matrix=placement_matrix(
[
roof_size.x / 2,
storey_size.y + 3 / 2 * wall_thickness + roof_ledge.y - roof_size.y / 2,
storey_size.z - roof_downward_offset + roof_size.z + roof_thickness / roof_angle_cos
], x_local=[-1., 0., 0.], z_local=[0., 1., 0.]
)
)
ios.aggregate.assign_object(file, product=south_roof, relating_object=roof)
ios.aggregate.assign_object(file, product=north_roof, relating_object=roof)
The ios
thing is just some artifact to avoid strings in ifcopenshell.api.run
.