https://github.com/chuongmep/ifc-to-excel
Convert Metadata From IFC To Excel
https://github.com/chuongmep/ifc-to-excel
autodesk big-data data ifc ifc-excel ifc-viewer
Last synced: about 1 year ago
JSON representation
Convert Metadata From IFC To Excel
- Host: GitHub
- URL: https://github.com/chuongmep/ifc-to-excel
- Owner: chuongmep
- License: mit
- Created: 2024-01-24T14:34:46.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-22T07:04:54.000Z (almost 2 years ago)
- Last Synced: 2025-03-30T17:46:09.103Z (over 1 year ago)
- Topics: autodesk, big-data, data, ifc, ifc-excel, ifc-viewer
- Language: Jupyter Notebook
- Homepage: https://chuongmep.com/posts/2024-02-25-Export-IFC-Excel-CSV.html
- Size: 5.46 MB
- Stars: 9
- Watchers: 2
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Description
Demo Easy Convert Data From IFC To Excel

## Installation
```bash
%pip install -U
%pip install ifcopenshell -U
%pip install openpyxl -U
%pip install pandas -U
%pip install lark -U
%pip install wordcloud -U
```
## Usage
```python
# copyring by chuongmep
import ifcopenshell
import pandas as pd
import warnings
warnings.filterwarnings('ignore')
file_path = r"2022020320211122Wellness center Sama.ifc"
ifc_file = ifcopenshell.open(file_path)
classes = ifc_file.by_type("IfcProduct")
class_names = [class_name.is_a() for class_name in classes]
class_names = list(set(class_names))
file_name = "result.xlsx"
with pd.ExcelWriter(file_name, engine='openpyxl') as writer:
for class_name in class_names:
objects = ifc_file.by_type(class_name)
result_df = pd.DataFrame()
for object in objects:
class_data = {}
psets = ifcopenshell.util.element.get_psets(object)
for name, value in psets.items():
if isinstance(value, dict):
for key, val in value.items():
class_data[key] = val
else:
pass
class_df = pd.DataFrame(class_data, index=[0])
result_df = pd.concat([result_df, class_df], ignore_index=True)
if(result_df.empty):
continue
result_df.to_excel(writer, sheet_name=class_name, index=False)
# set auto fit column width
worksheet = writer.sheets[class_name]
for idx, col in enumerate(worksheet.columns):
worksheet.column_dimensions[col[0].column_letter].width = 20
```
Visualize data use seaborn and matplotlib
```py
import matplotlib.pyplot as plt
import seaborn as sns
sns.set_theme(style="darkgrid")
# visualize data df dictionary, y is class name, x is number of objects
sns.barplot(y=list(df.keys()), x=[len(df[key]) for key in df.keys()])
plt.xticks(rotation=90)
plt.ylabel("Class name")
plt.xlabel("Number of objects")
plt.title("Visualization by Class")
plt.show()
```

## Sample Files
- [IFC_To_Excel.ipynb](./IFC_To_Excel.ipynb) - Demo convert data from IFC to Excel
- [Result.xlsx](./Result.xlsx) - Result file after convert
## CopyRight
- Model by [https://openifcmodel.cs.auckland.ac.nz/](https://openifcmodel.cs.auckland.ac.nz/)
- [IfcOpenShell 0.7.0 documentation](https://blenderbim.org/docs-python/autoapi/ifcopenshell/util/element/index.html#ifcopenshell.util.element.get_properties)