Thank you @Moult !
Following this approach I still don't get the right global placement
for index, story in enumerate(stories):
elevation = story['data']['elevation']
storey = ifcopenshell.api.run("root.create_entity", ifcfile, ifc_class="IfcBuildingStorey", name= str(index + 1).zfill(2) + " " + "Storey")
ifcopenshell.api.run("aggregate.assign_object", ifcfile, relating_object=building, product=storey)
for space in story['data']['children']:
points = space['data']['pts']
make_slab(ifcfile, sb, body, storey, points, slab_thickness=0.2)
m = np.eye(4)
m[:,3][0:3] = (0,0,elevation) # Set XYZ coordinates
ifcopenshell.api.run("geometry.edit_object_placement", ifcfile, product=storey, matrix=m, is_si=True, should_transform_children=True)
def make_slab(ifcfile, sb, body, storey, points, slab_thickness=0.2):
pts = convert_points(points)
profile = sb.polyline(pts)
slab = ifcopenshell.api.run("root.create_entity", ifcfile, ifc_class="IfcSlab", name="Slab")
extruded_solid = sb.extrude(profile, magnitude=slab_thickness, position=mathutils.Vector((0.0, 0.0, 0.0)), 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=slab, representation=representation)
ifcopenshell.api.run("spatial.assign_container", ifcfile, relating_structure=storey, product=slab)
ifcopenshell.api.run("aggregate.assign_object", ifcfile, relating_object=storey, product=slab)
ifcopenshell.api.run("geometry.edit_object_placement", ifcfile, product=slab)
create_style(ifcfile, representation, ColorRGB(.89, .89, .89))
