I have a case where I have a large IFC file in which I want to extract specific entities and their corresponding Psets and export them in a new IFC file. My approach is to iterate over all entities of the specified class and .add to the new file, but this does only extract the geometry and does not maintain its related psets..
Various discussions points out that NewIFC.createIfcRelDefinesByProperties function does it, but my limited expertise with IfcOpenshell makes me hit rock bottom trying to make it work.
I am using IfcOpenshell v0.7.0 and Python 3.10.7
importifcopenshell## load model begin ##print('Loading the model...')ifc_file='model\file.ifc'model=ifcopenshell.open(ifc_file)Entity="IfcFlowSegment"products=model.by_type(Entity)Pipe=[]forproductinproducts:ifproduct.is_a(Entity):Pipe.append(product)## Generating new file for export ## NewIfc=ifcopenshell.file(schema=model.schema)NewIfc.add(model.by_type('IfcProject')[0])## Iterative writing of objects ##foriinrange(len(Pipe)):NewIfc.add(products[i])NewIfc.write("V:/NewFile.ifc")print('Extrcation of '+str(Entity)+'´s completed!')
I am able to obtain all psets, properties, and values from every instance of the specified entity, but I am not sure how to proceed on adding them to their respective objects in the new file
I have a case where I have a large IFC file in which I want to extract specific entities and their corresponding Psets and export them in a new IFC file. My approach is to iterate over all entities of the specified class and .add to the new file, but this does only extract the geometry and does not maintain its related psets..
Various discussions points out that NewIFC.createIfcRelDefinesByProperties function does it, but my limited expertise with IfcOpenshell makes me hit rock bottom trying to make it work.
I am using IfcOpenshell v0.7.0 and Python 3.10.7
I am able to obtain all psets, properties, and values from every instance of the specified entity, but I am not sure how to proceed on adding them to their respective objects in the new file