How to add qto

Ck1Ck1
edited November 2023 in General

Hi I'm new to all this IfcOpenShell python.
I would like to add the GrossFloorArea to all the IfcSpaces that do not have this property. This property needs to be inside Qto_SpaceBaseQuentities.
If the IfcSpace does not have Qto_SpaceBaseQuentities then I would like to add Qto_SpaceBaseQuentities and GrossFloorArea to that IfcSpace.
My final problem is to save these pset/qto(?) into a new IfcFile. Hope some of you can help me, thank you.
My current script looks like this

import ifcopenshell
import ifcopenshell.api
model = ifcopenshell.open(r"C:\ifcopenshell-python-311-v0.7.0-dadcbe6-win64 (1)\model\model.ifc")
import ifcopenshell.util.element
spaces = model.by_type("IfcSpace")
samlet_gross_floor_area = 0.0
for space in spaces:
try:
pset = ifcopenshell.util.element.get_pset(space,"Qto_SpaceBaseQuantities",should_inherit=False,prop="GrossFloorArea")
qto = ifcopenshell.util.element.get_pset(space,"Qto_SpaceBaseQuantities",should_inherit=False)
except TypeError as e:
print("Space does not contain Qto_SpaceBaseQuantities")
continue
try:
print(pset)
samlet_gross_floor_area += pset
except Exception as e:
ifcopenshell.api.run("pset.edit_pset", model,
pset=model.by_id(qto["id"]), properties={"GrossFloorArea": 120})
print("Added grossfloorarea")
model.write(r"output.ifc")

Sign In or Register to comment.