Skip to content

smitelagwar/Python-muhendislik

Repository files navigation

Python DWG / BIM Yapısal Analiz Sistemi

Sıfır elle giriş. DXF, DWG ve IFC dosyalarını otomatik olarak parse eden, sınıflandıran, metraj hesaplayan, yönetmelik denetleyen ve AI raporlayan açık kaynak mühendislik platformu.


📐 Mimari — 4 Katmanlı Hibrit Analiz

 Gelen Dosya (.dxf / .dwg / .ifc)
        │
        ▼
┌─────────────────────────────────────────────┐
│  Katman 0 — BIM / IFC (Güven: 1.00)        │  ← ifcopenshell
│  Dosya .ifc ise direkt 3D obje okuma        │
└───────────────────┬─────────────────────────┘
                    │ değilse
                    ▼
┌─────────────────────────────────────────────┐
│  Katman 1 — Vektörel DXF (Güven ≥ 0.70)   │  ← ezdxf
│  Layer / Insert analizi + Regex kuralları   │
└───────────────────┬─────────────────────────┘
                    │ < 0.70
                    ▼
┌─────────────────────────────────────────────┐
│  Katman 2 — AI Layer Mapping (0.60-0.70)   │  ← Claude API
│  Tüm layer adlarını LLM'e gönder → YAML    │
└───────────────────┬─────────────────────────┘
                    │ < 0.60
                    ▼
┌─────────────────────────────────────────────┐
│  Katman 3 — Computer Vision (Güven < 0.60) │  ← YOLO + Claude Vision
│  DXF → PNG render → Bounding Box tespiti   │
└─────────────────────────────────────────────┘

🚀 Kurulum

Gereksinimler

Bileşen Sürüm Zorunlu
Python ≥ 3.10
ODA File Converter ≥ 25.x Sadece .dwg için
Redis ≥ 7.0 Opsiyonel (RQ Worker için)
Docker ≥ 24.0 Opsiyonel (Container için)

Hızlı Kurulum

# 1. Repoyu klonla
git clone https://github.com/youruser/python-dwg-okuma.git
cd python-dwg-okuma

# 2. Virtual environment
python -m venv venv
venv\Scripts\activate       # Windows
source venv/bin/activate    # Linux/macOS

# 3. Bağımlılıkları yükle
pip install -r requirements.txt

# 4. .env dosyasını oluştur
cp .env.example .env
# .env dosyasındaki ANTHROPIC_API_KEY alanını doldur

# 5. Test et
python main.py --input output/test_sample.dxf --format all

Docker ile Kurulum (Önerilen)

# .env dosyasını oluştur
cp .env.example .env

# Tüm servisleri ayağa kaldır
docker-compose up --build

# API: http://localhost:8000/docs
# Worker ve Redis otomatik başlar

⚡ Hızlı Başlangıç — 5 Dakikada İlk Analiz

# En basit kullanım — tüm çıktıları üret
python main.py --input proje.dxf --format all

# IFC (BIM) dosyasıyla
python main.py --input model.ifc --format all

# AI raporuyla
python main.py --input proje.dxf --format all --ai

# Sadece metraj + maliyet
python main.py --input proje.dxf --format quantity

# Yönetmelik denetimi
python main.py --input proje.dxf --format compliance

🖥️ CLI Komutları

Temel Analiz

python main.py --input <dosya> [SEÇENEKLER]

Seçenekler:
  --input     Girdi dosyası (.dxf, .dwg, .ifc)
  --output    Çıktı klasörü (varsayılan: output/)
  --format    Çıktı formatları: csv,xlsx,json,pdf,png,html,quantity,compliance,all

Yapay Zeka Modülü

# Genel AI raporu
python main.py --input proje.dxf --ai

# Spesifik soru sor
python main.py --input proje.dxf --question "Kolonların ortalama kesit alanı nedir?"

# İnteraktif sohbet modu
python main.py --input proje.dxf --chat

# İki revizyonu kıyasla
python main.py --compare rev1.dxf rev2.dxf

# Anomali tespiti
python main.py --input proje.dxf --detect-anomalies

Görsel AI (Faz 12)

# Hybrid mod (YOLO + Vision, varsayılan)
python main.py --input proje.dxf --detector hybrid --format png

# Sadece YOLO
python main.py --input proje.dxf --detector yolo

# Model eğitimi
python main.py --input proje.dxf --train

Çatışma Tespiti (Faz 14)

# Tek planda hem mimari hem statik
python main.py --clash --input proje.dxf

# Ayrı mimari ve statik planlar
python main.py --clash --arch-plan mimari.dxf --struct-plan statik.dxf

Otomasyon (Faz 10)

# Klasör izleyici (yeni dosyaları otomatik işler)
python main.py --watch ./input_folder/

# FastAPI sunucu
python main.py --serve --port 8000

# RQ Background Worker
python main.py --worker

🌐 API Endpoint'leri

Sunucu ayakta olduğunda Swagger UI: http://localhost:8000/docs

Dosya Analizi

# DXF/DWG/IFC yükle ve analiz başlat
curl -X POST http://localhost:8000/analyze \
  -F "file=@proje.dxf"

# Yanıt:
# {"job_id": "abc123", "status": "PENDING"}

İş Durumu

curl http://localhost:8000/status/abc123

# Yanıt:
# {"job_id": "abc123", "status": "FINISHED", "completed_steps": [...]}

Rapor İndirme

# Tüm çıktıları ZIP olarak indir
curl -O http://localhost:8000/report/abc123

AI'a Soru Sor (Streaming)

curl -X POST http://localhost:8000/ask/abc123 \
  -H "Content-Type: application/json" \
  -d '{"question": "Bu projede hangi elemanlar yönetmeliğe aykırı?"}'

İki İşi Karşılaştır

curl "http://localhost:8000/compare?job_id_1=abc123&job_id_2=def456"

Sağlık Kontrolü

curl http://localhost:8000/health
# {"status": "ok", "version": "1.0.0"}

📁 Desteklenen Formatlar

Girdi

Format Açıklama Analiz Katmanı Güven
.ifc IFC/BIM modeli Katman 0 (BIM) 1.00
.dxf AutoCAD çizimi Katman 1-3 0.40-1.00
.dwg AutoCAD ikili ODA → DXF dönüşümü 0.40-1.00

Çıktı

Format Komut İçerik
elements.csv --format csv Tüm elemanlar düz tablo
report.xlsx --format xlsx Grafik destekli Excel
data.json --format json API tüketimi için JSON
report.pdf --format pdf Resmi basılabilir rapor
plan.png --format png 2D yapı planı
plan.html --format html Dinamik Plotly haritası
quantity_report.xlsx --format quantity Metraj + maliyet
quantity_report.pdf --format quantity Metraj PDF
compliance_report.xlsx --format compliance TBDY 2018 + TS 500
compliance_report.pdf --format compliance Uygunluk PDF
detection_map.png YOLO/Vision aktifken Bounding box haritası
structural_report.json --ai AI yorumu
clash_report.xlsx --clash Çatışma raporu
clash_map.png --clash Çatışma görsel haritası

⚙️ Konfigürasyon Referansı (config/config.yaml)

# Katman Eşleşme Kuralları
layer_mapping:
  kolon:  ["KOLON*", "K[0-9]*", "COL*"]
  kiris:  ["KIRIS*", "KR*", "BEAM*"]
  perde:  ["PERDE*", "P[0-9]*", "WALL*"]
  doseme: ["DOSEME*", "D[0-9]*", "SLAB*"]

# Hibrit Analiz Eşikleri
hybrid_analyzer:
  layer1_threshold: 0.70   # Bu puanın üzerinde Katman 1 yeter
  layer2_threshold: 0.60   # Bu puanın üzerinde Katman 2 yeter

# AI Asistan
ai:
  model: "claude-opus-4-5"
  max_tokens: 4096
  temperature: 0.2
  max_history_turns: 20    # Konuşma hafızası

# YOLO Ayarları (Faz 12)
yolo:
  confidence: 0.45         # Tespit eşiği
  epochs: 50               # Transfer learning epoch sayısı
  imgsz: 640               # Görüntü boyutu
  auto_retrain: false      # Otomatik yeniden eğitim

# Otomasyon (Faz 10)
automation:
  watch_folder: "./input_folder/"
  api_port: 8000
  notification:
    email_enabled: false
    telegram_enabled: false

# Birim Fiyatları (Faz 7)
unit_prices:
  beton_m3: 2500           # TL/m³
  demir_kg: 35             # TL/kg
  kalip_m2: 150            # TL/m²

🏗️ Proje Yapısı

python-dwg-okuma/
├── main.py                     # CLI giriş noktası
├── config/
│   ├── config.yaml             # Ana konfigürasyon
│   └── rules.yaml              # TBDY 2018 + TS 500 kuralları
├── src/
│   ├── core/                   # Çekirdek okuma ve analiz
│   │   ├── dwg_reader.py       # DXF parser (ezdxf)
│   │   ├── classifier.py       # Layer sınıflandırıcı
│   │   ├── hybrid_analyzer.py  # 4 katmanlı yönlendirici
│   │   ├── ifc_reader.py       # IFC/BIM okuyucu (Faz 11)
│   │   ├── vision_analyzer.py  # YOLO + Claude Vision (Faz 12)
│   │   ├── opening_reader.py   # Kapı/pencere okuyucu (Faz 14)
│   │   └── element_models.py   # Column/Beam/ShearWall/Slab/Opening
│   ├── analyzers/              # Element bazlı geometrik analizörler
│   ├── exporters/              # CSV/Excel/PDF/PNG/HTML çıktılar
│   ├── quantity/               # Metraj & maliyet (Faz 7)
│   ├── compliance/             # TBDY & TS 500 denetimi (Faz 8)
│   ├── ai/                     # Claude AI asistan (Faz 9)
│   ├── automation/             # Watcher/API/Worker (Faz 10)
│   └── clash/                  # Çatışma tespiti (Faz 14)
├── tests/                      # Tüm birim testler
├── prompts/                    # AI prompt şablonları
├── models/                     # Eğitilmiş YOLO modelleri
├── datasets/                   # YOLO eğitim veri setleri
├── Dockerfile
├── docker-compose.yml
├── requirements.txt
└── .env.example

🧪 Test

# Tüm testleri coverage ile koş
pytest tests/ -v --cov=src --cov-report=term-missing

# Sadece belirli bir faz testi
pytest tests/test_clash_detection.py -v
pytest tests/test_compliance.py -v
pytest tests/test_ifc_reader.py -v

📄 Lisans

MIT License — Ticari kullanım dahil serbestçe kullanılabilir.


🤝 Katkı

  1. Fork yap
  2. Feature branch oluştur (git checkout -b feature/yeni-ozellik)
  3. Testlerini yaz ve koştur (pytest tests/ -v)
  4. PR aç

About

python muhendislik complex yapı

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors