微算力 · API 导航与自营网关
API 接入 EN
未登录登录
🏗️

BIM工程量智能提取专家

bim-qto · vv2.1.0
专业技能 安全 S 级 作者 datadrivenconstruction 公开目录收录
下载 2k 安装 709 收藏 5.7k 浏览 29.8k
原始页面

简介

基于pandas/openpyxl的BIM工程量提取工具,支持Revit等导出数据的多维分组统计与Excel报表生成,助力建筑成本估算效率提升。

原始描述

Extract quantities from BIM/CAD data for cost estimation. Group by type, level, zone. Generate QTO reports.

中文使用说明 来自收录源

核心用法

BIM QTO是一款专注于建筑信息模型工程量提取的自动化工具。它通过解析Revit等BIM软件导出的Excel/CSV数据,智能识别列名映射(支持Type、Category、Level、Volume等20+种变体),提供多维度的数量统计功能:

  • 分组统计:按构件类型、专业类别、建筑楼层自动聚合工程量
  • 矩阵透视:生成楼层×类型交叉分析表,直观展示各层构件分布
  • 构件快捷提取:内置墙体、楼板、门窗等常见构件一键提取方法
  • 报表导出:自动生成多工作表Excel,包含分类汇总、类型清单、楼层矩阵及专项构件表

使用流程

  1. 从Revit/ArchiCAD等导出构件明细表为Excel
  2. 用pandas读取数据初始化BIMQuantityTakeoff对象
  3. 调用分组方法获取统计结果,或使用to_excel()生成完整报表

显著优点

优势 说明
智能列识别 自动匹配中英文、大小写、空格等20+种列名变体,无需手动映射
计量单位完备 内置计数、长度、面积、体积、重量及英制单位枚举
容错设计 当某列缺失时自动降级为计数模式,不中断流程
专业场景覆盖 预置墙体、门窗、楼板等AEC行业高频构件提取方法
结构化输出 返回QTOReport数据类,便于后续系统集成

局限性与注意事项

数据依赖性强:完全依赖BIM导出数据质量,若模型中几何信息不完整(如未计算体积),则无法获取相应工程量,仅能回退到计数模式。

列识别非100%覆盖:虽支持主流列名变体,但特殊定制字段或非常规BIM平台导出格式可能无法自动识别,需手动预处理。

Excel引擎依赖:导出功能依赖openpyxl,处理超大型项目(数十万级构件)时可能存在内存和性能瓶颈。

裸异常捕获:to_excel方法中使用裸try/except,可能掩盖真正的数据错误,建议生产环境补充日志记录。

适合人群

  • 造价工程师:替代手工Excel汇总,自动化生成招标工程量清单
  • BIM工程师:快速校验模型完整度,检查各楼层构件分布
  • 项目经理:获取粗量级成本估算数据,支持前期决策
  • 施工管理人员:按楼层/区域提取物料需求,辅助进度计划

常规风险提示

  1. 数据准确性责任:工具仅执行统计计算,不验证BIM模型几何正确性,关键项目建议结合专业算量软件复核
  2. 版本兼容性:不同Revit版本导出的列名可能存在差异,首次使用需验证列识别结果
  3. 单位一致性:若原始数据混用公制/英制,需统一换算后再导入,工具本身不做单位转换

安全认证摘要

经CLS-Certify v2.1.0六维扫描,获**S级(95分)**安全评级。纯本地数据处理,无网络调用、无系统命令、无隐私数据外泄,依赖仅pandas/numpy标准库,T2可信组织来源。

技能正文


slug: "bim-qto" display_name: "BIM QTO" description: "Extract quantities from BIM/CAD data for cost estimation. Group by type, level, zone. Generate QTO reports."

BIM Quantity Takeoff

Overview

Quantity Takeoff (QTO) extracts measurable quantities from BIM models. This skill processes BIM exports to generate grouped quantity reports for cost estimation.

Python Implementation

import pandas as pd
import numpy as np
from typing import Dict, Any, List, Optional, Tuple
from dataclasses import dataclass, field
from enum import Enum


class QTOUnit(Enum):
    """Quantity takeoff measurement units."""
    COUNT = "ea"
    LENGTH = "m"
    AREA = "m2"
    VOLUME = "m3"
    WEIGHT = "kg"
    LINEAR_FOOT = "lf"
    SQUARE_FOOT = "sf"
    CUBIC_YARD = "cy"


@dataclass
class QTOItem:
    """Single QTO line item."""
    category: str
    type_name: str
    description: str
    quantity: float
    unit: str
    level: Optional[str] = None
    material: Optional[str] = None
    element_count: int = 0


@dataclass
class QTOReport:
    """Complete QTO report."""
    project_name: str
    items: List[QTOItem]
    total_elements: int
    categories: int
    generated_date: str


class BIMQuantityTakeoff:
    """Extract quantities from BIM data."""

    # Column mappings for different BIM exports
    COLUMN_MAPPINGS = {
        'type': ['Type Name', 'TypeName', 'type_name', 'Family and Type', 'IfcType'],
        'category': ['Category', 'category', 'IfcClass', 'Element Category'],
        'level': ['Level', 'level', 'Building Storey', 'BuildingStorey', 'Floor'],
        'volume': ['Volume', 'volume', 'Volume (m³)', 'Qty_Volume'],
        'area': ['Area', 'area', 'Surface Area', 'Area (m²)', 'Qty_Area'],
        'length': ['Length', 'length', 'Length (m)', 'Qty_Length'],
        'count': ['Count', 'count', 'Quantity', 'ElementCount'],
        'material': ['Material', 'material', 'Structural Material', 'MaterialName']
    }

    def __init__(self, df: pd.DataFrame):
        """Initialize with BIM data DataFrame."""
        self.df = df
        self.column_map = self._detect_columns()

    def _detect_columns(self) -> Dict[str, str]:
        """Detect which columns exist in data."""
        mapping = {}

        for standard, variants in self.COLUMN_MAPPINGS.items():
            for variant in variants:
                if variant in self.df.columns:
                    mapping[standard] = variant
                    break

        return mapping

    def get_column(self, standard_name: str) -> Optional[str]:
        """Get actual column name from standard name."""
        return self.column_map.get(standard_name)

    def group_by_type(self, sum_column: str = 'volume') -> pd.DataFrame:
        """Group quantities by type name."""

        type_col = self.get_column('type')
        qty_col = self.get_column(sum_column)

        if type_col is None:
            raise ValueError("Type column not found")

        if qty_col is None:
            # Fall back to count
            result = self.df.groupby(type_col).size().reset_index(name='count')
        else:
            result = self.df.groupby(type_col).agg({
                qty_col: 'sum'
            }).reset_index()
            result['count'] = self.df.groupby(type_col).size().values

        result.columns = ['Type', 'Quantity', 'Count'] if len(result.columns) == 3 else ['Type', 'Count']
        return result.sort_values('Count', ascending=False)

    def group_by_category(self, sum_column: str = 'volume') -> pd.DataFrame:
        """Group quantities by category."""

        cat_col = self.get_column('category')
        qty_col = self.get_column(sum_column)

        if cat_col is None:
            raise ValueError("Category column not found")

        agg_dict = {}
        if qty_col:
            agg_dict[qty_col] = 'sum'

        if agg_dict:
            result = self.df.groupby(cat_col).agg(agg_dict).reset_index()
            result['count'] = self.df.groupby(cat_col).size().values
        else:
            result = self.df.groupby(cat_col).size().reset_index(name='count')

        return result.sort_values('count', ascending=False)

    def group_by_level(self, sum_column: str = 'volume') -> pd.DataFrame:
        """Group quantities by building level."""

        level_col = self.get_column('level')
        qty_col = self.get_column(sum_column)

        if level_col is None:
            raise ValueError("Level column not found")

        agg_dict = {}
        if qty_col:
            agg_dict[qty_col] = 'sum'

        if agg_dict:
            result = self.df.groupby(level_col).agg(agg_dict).reset_index()
            result['count'] = self.df.groupby(level_col).size().values
        else:
            result = self.df.groupby(level_col).size().reset_index(name='count')

        return result

    def pivot_by_level_and_type(self) -> pd.DataFrame:
        """Create pivot table: levels as rows, types as columns."""

        level_col = self.get_column('level')
        type_col = self.get_column('type')

        if level_col is None or type_col is None:
            raise ValueError("Level or Type column not found")

        pivot = pd.crosstab(
            self.df[level_col],
            self.df[type_col],
            margins=True
        )

        return pivot

    def filter_by_category(self, categories: List[str]) -> 'BIMQuantityTakeoff':
        """Filter to specific categories."""

        cat_col = self.get_column('category')
        if cat_col is None:
            raise ValueError("Category column not found")

        filtered_df = self.df[self.df[cat_col].isin(categories)]
        return BIMQuantityTakeoff(filtered_df)

    def filter_by_level(self, levels: List[str]) -> 'BIMQuantityTakeoff':
        """Filter to specific levels."""

        level_col = self.get_column('level')
        if level_col is None:
            raise ValueError("Level column not found")

        filtered_df = self.df[self.df[level_col].isin(levels)]
        return BIMQuantityTakeoff(filtered_df)

    def get_walls(self) -> pd.DataFrame:
        """Get wall quantities."""
        cat_col = self.get_column('category')
        if cat_col:
            walls = self.df[self.df[cat_col].str.contains('Wall', case=False, na=False)]
            return BIMQuantityTakeoff(walls).group_by_type()
        return pd.DataFrame()

    def get_floors(self) -> pd.DataFrame:
        """Get floor/slab quantities."""
        cat_col = self.get_column('category')
        if cat_col:
            floors = self.df[self.df[cat_col].str.contains('Floor|Slab', case=False, na=False)]
            return BIMQuantityTakeoff(floors).group_by_type()
        return pd.DataFrame()

    def get_doors(self) -> pd.DataFrame:
        """Get door quantities."""
        cat_col = self.get_column('category')
        if cat_col:
            doors = self.df[self.df[cat_col].str.contains('Door', case=False, na=False)]
            return BIMQuantityTakeoff(doors).group_by_type()
        return pd.DataFrame()

    def get_windows(self) -> pd.DataFrame:
        """Get window quantities."""
        cat_col = self.get_column('category')
        if cat_col:
            windows = self.df[self.df[cat_col].str.contains('Window', case=False, na=False)]
            return BIMQuantityTakeoff(windows).group_by_type()
        return pd.DataFrame()

    def generate_report(self, project_name: str = "Project") -> QTOReport:
        """Generate complete QTO report."""

        from datetime import datetime

        items = []
        type_col = self.get_column('type')
        cat_col = self.get_column('category')
        level_col = self.get_column('level')
        vol_col = self.get_column('volume')
        area_col = self.get_column('area')
        mat_col = self.get_column('material')

        # Group by type
        grouped = self.df.groupby(type_col if type_col else self.df.columns[0])

        for type_name, group in grouped:
            # Determine primary quantity
            qty = 0
            unit = QTOUnit.COUNT.value

            if vol_col and vol_col in group.columns:
                qty = group[vol_col].sum()
                unit = QTOUnit.VOLUME.value
            elif area_col and area_col in group.columns:
                qty = group[area_col].sum()
                unit = QTOUnit.AREA.value
            else:
                qty = len(group)
                unit = QTOUnit.COUNT.value

            # Get category and material
            category = group[cat_col].iloc[0] if cat_col and cat_col in group.columns else ""
            material = group[mat_col].iloc[0] if mat_col and mat_col in group.columns else ""
            level = group[level_col].iloc[0] if level_col and level_col in group.columns else ""

            items.append(QTOItem(
                category=str(category),
                type_name=str(type_name),
                description=str(type_name),
                quantity=round(qty, 2),
                unit=unit,
                level=str(level) if level else None,
                material=str(material) if material else None,
                element_count=len(group)
            ))

        return QTOReport(
            project_name=project_name,
            items=items,
            total_elements=len(self.df),
            categories=self.df[cat_col].nunique() if cat_col else 0,
            generated_date=datetime.now().isoformat()
        )

    def to_excel(self, output_path: str, project_name: str = "Project"):
        """Export QTO to Excel with multiple sheets."""

        with pd.ExcelWriter(output_path, engine='openpyxl') as writer:
            # Summary by category
            self.group_by_category().to_excel(
                writer, sheet_name='By Category', index=False)

            # Summary by type
            self.group_by_type().to_excel(
                writer, sheet_name='By Type', index=False)

            # Level breakdown
            try:
                self.pivot_by_level_and_type().to_excel(
                    writer, sheet_name='Level-Type Matrix')
            except:
                pass

            # Walls
            walls = self.get_walls()
            if not walls.empty:
                walls.to_excel(writer, sheet_name='Walls', index=False)

            # Doors and Windows
            doors = self.get_doors()
            if not doors.empty:
                doors.to_excel(writer, sheet_name='Doors', index=False)

            windows = self.get_windows()
            if not windows.empty:
                windows.to_excel(writer, sheet_name='Windows', index=False)

        return output_path

Quick Start

# Load BIM export
df = pd.read_excel("revit_export.xlsx")

# Initialize QTO
qto = BIMQuantityTakeoff(df)

# Get quantities by type
by_type = qto.group_by_type()
print(by_type.head(10))

# Get wall schedule
walls = qto.get_walls()
print(walls)

Common Use Cases

1. Full QTO Report

qto = BIMQuantityTakeoff(df)
report = qto.generate_report("Office Building")
print(f"Elements: {report.total_elements}")
for item in report.items[:5]:
    print(f"{item.type_name}: {item.quantity} {item.unit}")

2. Level-by-Level Analysis

pivot = qto.pivot_by_level_and_type()
print(pivot)

3. Export to Excel

qto.to_excel("qto_report.xlsx", "My Project")

Resources

  • DDC Book: Chapter 3.2 - Quantity Take-Off

正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。

其他来源收录

同一技能在不同目录的原始页面:

标签

real-estatedata-analyticsproductivitydocsautomationproject-program-management

同类 Skill