# Data Enrichment Tool

This folder contains the Python tools for processing 3D models and Excel metadata into BIM files for the web viewer.

## What it does

```
Input:  .gltf (3D model)  +  .xlsx (metadata)
Output: .ifc  +  .xkt  +  _metadata.json
```

## Prerequisites

Before running the tool, install:

1. **Python 3.9 or newer** — [python.org](https://www.python.org/downloads/)
   - During installation, check **"Add Python to PATH"**

2. **Node.js 16 or newer** — [nodejs.org](https://nodejs.org/)
   - Then install xeokit-convert:
     ```
     npm install -g @xeokit/xeokit-convert
     ```

## First-time setup

Run this once to create a Python virtual environment and install all dependencies:

```
setup_env.bat
```

## Running the tool

```
run_enrichment.bat
```

This opens the graphical interface. Fill in:
- **GLTF Model** — your exported 3D model (`.gltf` or `.glb`)
- **Excel Data** — your metadata sheet (`.xlsx`)
- **Output Folder** — where to save results
- **File Name** — base name for all output files

Click **"Convert to IFC"** and wait. When done, close the window — the `.bat` script will continue automatically to generate the `.xkt` and `_metadata.json` files.

## Command-line usage (advanced)

You can also run the conversion directly from the command line:

```bash
# Only IFC (Python required, no Node.js)
python src\gltf_to_ifc_converter.py --gltf model.gltf --excel data.xlsx --output output\model.ifc

# Full pipeline via gh_data_integration.py
python src\gh_data_integration.py --excel data.xlsx --gltf model.gltf --output-dir output\
```

## Output files

| File | Use |
|------|-----|
| `model.ifc` | Standard IFC BIM file — open in Revit, ArchiCAD, BIM Vision |
| `model.xkt` | Optimized for the web viewer — upload to WordPress |
| `model_metadata.json` | Property data for the viewer — upload next to `model.xkt` |

## File structure

```
02_data_enrichment/
├── setup_env.bat              ← run once to install Python deps
├── run_enrichment.bat         ← main launcher (opens GUI, then converts)
├── enrichment_gui.py          ← GUI source code
├── requirements.txt           ← Python dependencies
└── src/
    ├── gh_data_integration.py     ← pipeline orchestration script
    └── gltf_to_ifc_converter.py   ← GLTF → IFC conversion logic
```

## Troubleshooting

| Error | Solution |
|-------|---------|
| `python is not recognized` | Reinstall Python with "Add to PATH" checked |
| `xeokit-convert not found` | Run `npm install -g @xeokit/xeokit-convert` |
| `venv errors` | Delete the `venv/` folder (if present) and rerun `setup_env.bat` |
| IFC created but XKT fails | Check Node.js installation and xeokit-convert |
