How can I split an ifc file, for example, that consists of six walls into six ifc files? I tried to do it as follows:
for i in range(len(assembly_walls)):
element_id = assembly_walls[i].id()
model = ifcopenshell.file(schema=ifc_object.schema)
model.add(ifc_object.by_type('IfcElementAssembly')[i])
model.write(output_file_path).
However, I was getting only this part:
ISO-10303-21;
HEADER;
FILE_DESCRIPTION(('ViewDefinition [CoordinationView]'),'2;1');
FILE_NAME('','2024-04-29T19:34:38',(),(),'IfcOpenShell v0.7.0-f7c03db75','IfcOpenShell v0.7.0-f7c03db75','');
FILE_SCHEMA(('IFC4'));
ENDSEC;
DATA;
How can I split an ifc file, for example, that consists of six walls into six ifc files? I tried to do it as follows:
for i in range(len(assembly_walls)):
element_id = assembly_walls[i].id()
model = ifcopenshell.file(schema=ifc_object.schema)
model.add(ifc_object.by_type('IfcElementAssembly')[i])
model.write(output_file_path).
However, I was getting only this part:
ISO-10303-21;
HEADER;
FILE_DESCRIPTION(('ViewDefinition [CoordinationView]'),'2;1');
FILE_NAME('','2024-04-29T19:34:38',(),(),'IfcOpenShell v0.7.0-f7c03db75','IfcOpenShell v0.7.0-f7c03db75','');
FILE_SCHEMA(('IFC4'));
ENDSEC;
DATA;
1=IFCPERSON($,'\X2\041B0430043D044C\X0\','\X2\041C043804400430\X0\',$,$,$,$,$);
2=IFCORGANIZATION($,'No Organization',$,$,$);
3=IFCPERSONANDORGANIZATION(#1,#2,$);
4=IFCAPPLICATION(#2,'2023.1','Allplan','Allplan');
5=IFCOWNERHISTORY(#3,#4,$,.NOTDEFINED.,$,$,$,1714392219);
6=IFCCARTESIANPOINT((0.,0.,0.));
7=IFCAXIS2PLACEMENT3D(#6,$,$);
8=IFCLOCALPLACEMENT($,#7);
9=IFCCARTESIANPOINT((-0.0874455090274132,0.599320606250614,0.));
10=IFCDIRECTION((-0.,-1.,-0.));
11=IFCDIRECTION((1.,-0.,-0.));
12=IFCAXIS2PLACEMENT3D(#9,#10,#11);
13=IFCLOCALPLACEMENT(#8,#12);
14=IFCELEMENTASSEMBLY('0RUtl0QTvDfglu8PSNFbVn',#5,'3','\X2\042104420435043D0430\X0-\X2\0441044D043D0434043204380447\X0\','ELEMENT',#13,$,$,$,.USERDEFINED.);
ENDSEC;
END-ISO-10303-21;
Are there any ifcopenshell tools to easily split ifc files into parts?
Thanks.
Have a look at ifcpatch with the ExtractElements recipe. https://docs.ifcopenshell.org/autoapi/ifcpatch/recipes/ExtractElements/index.html#module-ifcpatch.recipes.ExtractElements
Thank you for your help!