@Moult said:
In IFC, attributes are fixed. If you want to add arbitrary properties, use property sets, not attributes. This is as @Coen has explained. However, there is a simpler method using the IfcOpenShell API.
import ifcopenshell
import ifcopenshell.api
ifc = ifcopenshell.open('path\to_your\ifc_file')
element = ifc.by_type("IfcElement")[0] # Just as an example, you will need to select the elements you want to add properties to yourself.
pset = ifcopenshell.api.run("pset.add_pset", ifc, product=element, name="Your Property Set Name")
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"foo": "foobar", "foo2": "foobaz"})
this code is not working for me, I don't have much experience with ifc.
Im trying to assign parameters coming from excel file.
f = ifcopenshell.open(ifc_path)
df = pd.read_excel(xls_path), sheet_name="CONCRETE")
for index, row in df.iterrows():
ifcguid = row['IfcGUID']
el = f.by_id(ifcguid)
pset = ifcopenshell.api.run("pset.add_pset", f, product=el, name="Pset_AsBuilt")
ifcopenshell.api.run("pset.edit_pset", f, pset=pset, properties=row)
f.write(ifc_path)
and it looks like they do get assigned to elements but they are not visible in bim viewer/blender.
Comments
Hi,
this code is not working for me, I don't have much experience with ifc.
Im trying to assign parameters coming from excel file.
and it looks like they do get assigned to elements but they are not visible in bim viewer/blender.
this is ifc file after editing. for example: