First of all: thanks for the great Tutorials on IfcOpenShell. Without those I wouldn't know where to even begin! Getting that out of the way, I'm very new to the Ifc format and therefore very new to IfcOpenShell.
I have a wall object with a pset attached to the material properties. Now I want to change a value of one of the material properties. In this case it's about "Test2" which should take the value of "Test1". This means I have to a) extract the value of "Test1" (which is 0.629...) and replace the value of "Test2" by exactly that number.
I've managed to do that in Python, however, I don't know how to proceed from there to "persist" or write the ifc file with the new values. This is what my current code looks like:
import ifcopenshell
import ifcopenshell.util
import ifcopenshell.util.element
import ifcopenshell.util.pset
import ifcopenshell.geom
ifc = ifcopenshell.open("./ifc_file.ifc")
materials = ifc.by_type("IfcMaterial")
wall = ifc.by_type("IfcWall")[0]
for material in materials:
psets = ifcopenshell.util.element.get_psets(material)
for key, pset in psets.items():
if key.startswith("HHLA"):
print(pset)
pset["Test2"] = pset["Test1"]
print(pset)
The question is: how exactly do I manage to write an updated ifc file with everything being the same as the old ifc file but the new entries for Test2? When using "write", I end up having the same file which I had before.
If anything is unclear or if there is a much less complicated way to achieve what I want to do, please let me know.
I've uploaded an excerpt of what the IFC file looks like in FZKViewer here: https://community.osarch.org/uploads/editor/1b/zlmpu5jlz2cj.png