Skip to content

SustainableUrbanSystemsLab/ARCH-8833-Sp25-LLM2IFC

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🏗️ Text-to-IFC Playground

Generate 3-D BIM (IFC) blocks from plain-language instructions with an LLM, a tiny mesh parser, and IfcOpenShell.

Python IfcOpenShell OpenAI API


Table of Contents

  1. Why this exists
  2. Process Overview
  3. How it works (TL;DR)
  4. Repository Layout
  5. Quick Start
  6. Detailed Workflow
  7. Implementation Decisions
  8. Limitations & Future Work
  9. References

✨ Why this exists

“Can we ask ChatGPT for a building or general 3d models, the same way we ask it to generate code, and open the result in Revit?”

Our intent is to make the workflow:

  1. Re-usable – you can swap GPT-4o-mini for another chat model.
  2. Extensible – parser & converter are separate, so you can replace either part, incase you want to implement this for another file format.

🚦 Process Overview

  1. 🗣️ LLM → produce an OBJ mesh in a fenced code-block.
  2. 🧹 Extract OBJ lines from the chat response.
  3. 🔎 Parse vertices & faces.
  4. 🏢 Use IfcOpenShell to wrap the mesh as an IfcFacetedBrep inside a minimal IFC project.
  5. 👀 Open GeneratedBlock.ifc in Revit.

How it works (TL;DR)

graph TD
    A("User prompt: _'Generate a small rectangular building block.'_") -->|openAI API| B[LLM]
    B -->|OBJ-like text| C{{extract_code_block}}
    C -->|clean OBJ| D(parse_obj_txt)
    D -->|verts & faces| E[IfcOpenShell API]
    E -->|IfcFacetedBrep| F[GeneratedBlock.ifc]
Loading

Repository Layout

.
├─ src/
│  ├─ 01_prompt_llm.py
│  ├─ 02_parse_mesh.py
│  └─ 03_mesh_to_ifc.py
├─ examples/
│  ├─ bim_object.ifc
│  ├─ obj_mess.txt
│  └─ parsed_mesh.txt
├─ requirements.txt
└─ README.md

⚡ Quick Start

1 · Clone & set-up

git clone https://github.com/jma1999/ARCH-8833-Sp25-LLM2IFC.git
pip install -r requirements.txt

2 · Add your OpenAI API key

setx OPENAI_API_KEY "sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

3 · Run the pipeline end-to-end

python src/01_prompt_llm.py "Generate a simple small rectangular building block."
python src/02_parse_mesh.py
python src/03_mesh_to_ifc.py

open GeneratedBlock.ifc          # or open in Revit


🔍 Detailed Workflow

Step Script / File Purpose (what it does) Key Points
1 src/01_prompt_llm.py Send prompt to LLM, save full response → obj_mess.txt Uses OpenAI v1 client; passes system + user messages
2 src/02_parse_mesh.py Parse vertices & faces into Python lists; save summary → parsed_mesh.txt Accepts quads or tris, 1-based indices
3 src/03_mesh_to_ifc.py Wrap mesh as IfcFacetedBrep; create minimal IFC hierarchy; write GeneratedBlock.ifc Relies on ifcopenshell.api high-level helpers

Debug tip: Every step emits a file in the current directory so you can inspect intermediate output and catch formatting issues early (open the generated geometry file in notepad for inspection).


⚙️ Implementation Decisions

Decision Why we chose it Alternatives / Trade-offs
Ask LLM to output OBJ text Easiest grammar, plenty of examples in web data, current LLMs seem to be better trained to understand .obj file formats for meshes, simple to parse. Ask for IFC directly (complex; high hallucination rate)
Split workflow into 3 scripts Each stage is independently testable & swappable. Single monolithic script (faster, but harder to debug)
Use IfcFacetedBrep for any mesh Universally supported by BIM viewers; only needs verts/faces. Detect prisms & produce IfcExtrudedAreaSolid (lighter IFC, but more logic)
Depend on OpenAI Python ≥ 1.0 Future-proof; uses client.chat.completions.create. Pin to openai==0.28 & legacy API (simpler for old code)

⚠️ Limitations & Future Work

Current Limitations

  • Geometry fidelity depends entirely on LLM output (no mesh healing).
  • Only one OBJ block per run → one IFC product.
  • No semantics: created element = IfcBuildingElementProxy.
  • No unit handling; assumes meters & global origin.
  • Error handling is minimal—malformed OBJ will raise.

Planned / Wanted Features

  • Mesh validation via trimesh or similar.
  • Multi-object prompts → multiple IFC entities in one file.
  • Auto-detect extrusions for parametric solids (IfcExtrudedAreaSolid).
  • Config file to swap in local Hugging Face chat models (llama.cpp, etc.).
  • Add IFC metadata (owner history, units, placement, GUID).
  • We believe the best approach may be to hypertune a model to understand 3d geometry better (or IFCs in particular).

📚 References


About

BIM Copilot: Using an LLM to generate IFCs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%