rvt-to-excel
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseRVT to Excel Conversion
RVT转Excel转换
Business Case
业务场景
Problem Statement
问题描述
BIM data inside RVT files needs to be extracted for:
- Processing multiple projects in batch
- Integrating BIM data with analytics pipelines
- Sharing structured data with stakeholders
- Generating reports and quantity takeoffs
RVT文件中的BIM数据需要提取,以满足以下需求:
- 批量处理多个项目
- 将BIM数据集成到分析流水线
- 向利益相关者共享结构化数据
- 生成报表和工程量统计
Solution
解决方案
Convert RVT files to structured Excel databases for analysis and reporting.
将RVT文件转换为结构化Excel数据库,用于分析和报表生成。
Business Value
业务价值
- Batch processing - Convert multiple projects
- Data accessibility - Excel format for universal access
- Pipeline integration - Feed data to BI tools, ML models
- Structured output - Organized element data and properties
- 批量处理 - 转换多个项目
- 数据可访问性 - Excel格式支持通用访问
- 流水线集成 - 为BI工具、机器学习模型提供数据
- 结构化输出 - 组织化的构件数据和属性
Technical Implementation
技术实现
CLI Syntax
CLI 语法
bash
RvtExporter.exe <input_path> [export_mode] [options]bash
RvtExporter.exe <input_path> [export_mode] [options]Export Modes
导出模式
| Mode | Categories | Description |
|---|---|---|
| 309 | Essential structural elements |
| 724 | Standard BIM categories |
| 1209 | All Revit categories |
| User-defined | Specific categories only |
| 模式 | 类别数量 | 描述 |
|---|---|---|
| 309 | 核心结构构件 |
| 724 | 标准BIM类别 |
| 1209 | 所有Revit类别 |
| 用户自定义 | 仅特定类别 |
Options
可选参数
| Option | Description |
|---|---|
| Include bounding box coordinates |
| Include room associations |
| Export all schedules to sheets |
| Export sheets to PDF |
| 参数 | 描述 |
|---|---|
| 包含 bounding box 坐标 |
| 包含房间关联信息 |
| 将所有明细表导出为工作表 |
| 将图纸导出为PDF |
Examples
示例
bash
undefinedbash
undefinedBasic export
Basic export
RvtExporter.exe "C:\Projects\Building.rvt" basic
RvtExporter.exe "C:\Projects\Building.rvt" basic
Complete with bounding boxes
Complete with bounding boxes
RvtExporter.exe "C:\Projects\Building.rvt" complete bbox
RvtExporter.exe "C:\Projects\Building.rvt" complete bbox
Full export with all options
Full export with all options
RvtExporter.exe "C:\Projects\Building.rvt" complete bbox rooms schedules sheets
RvtExporter.exe "C:\Projects\Building.rvt" complete bbox rooms schedules sheets
Batch processing
Batch processing
for /R "C:\Projects" %f in (*.rvt) do RvtExporter.exe "%f" standard bbox
undefinedfor /R "C:\Projects" %f in (*.rvt) do RvtExporter.exe "%f" standard bbox
undefinedPython Integration
Python 集成
python
import subprocess
import pandas as pd
from pathlib import Path
from typing import List, Optional
class RevitExporter:
def __init__(self, exporter_path: str = "RvtExporter.exe"):
self.exporter = Path(exporter_path)
if not self.exporter.exists():
raise FileNotFoundError(f"RvtExporter not found: {exporter_path}")
def convert(self, rvt_file: str, mode: str = "complete",
options: List[str] = None) -> Path:
"""Convert Revit file to Excel."""
rvt_path = Path(rvt_file)
if not rvt_path.exists():
raise FileNotFoundError(f"Revit file not found: {rvt_file}")
cmd = [str(self.exporter), str(rvt_path), mode]
if options:
cmd.extend(options)
result = subprocess.run(cmd, capture_output=True, text=True)
if result.returncode != 0:
raise RuntimeError(f"Export failed: {result.stderr}")
# Output file is same name with .xlsx extension
output_file = rvt_path.with_suffix('.xlsx')
return output_file
def batch_convert(self, folder: str, mode: str = "standard",
pattern: str = "*.rvt") -> List[Path]:
"""Convert all Revit files in folder."""
folder_path = Path(folder)
converted = []
for rvt_file in folder_path.glob(pattern):
try:
output = self.convert(str(rvt_file), mode)
converted.append(output)
print(f"Converted: {rvt_file.name}")
except Exception as e:
print(f"Failed: {rvt_file.name} - {e}")
return converted
def read_elements(self, xlsx_file: str) -> pd.DataFrame:
"""Read converted Excel as DataFrame."""
return pd.read_excel(xlsx_file, sheet_name="Elements")
def get_quantities(self, xlsx_file: str,
group_by: str = "Category") -> pd.DataFrame:
"""Get quantity summary grouped by category."""
df = self.read_elements(xlsx_file)
# Group and count
summary = df.groupby(group_by).agg({
'ElementId': 'count',
'Area': 'sum',
'Volume': 'sum'
}).reset_index()
summary.columns = [group_by, 'Count', 'Total_Area', 'Total_Volume']
return summarypython
import subprocess
import pandas as pd
from pathlib import Path
from typing import List, Optional
class RevitExporter:
def __init__(self, exporter_path: str = "RvtExporter.exe"):
self.exporter = Path(exporter_path)
if not self.exporter.exists():
raise FileNotFoundError(f"RvtExporter not found: {exporter_path}")
def convert(self, rvt_file: str, mode: str = "complete",
options: List[str] = None) -> Path:
"""Convert Revit file to Excel."""
rvt_path = Path(rvt_file)
if not rvt_path.exists():
raise FileNotFoundError(f"Revit file not found: {rvt_file}")
cmd = [str(self.exporter), str(rvt_path), mode]
if options:
cmd.extend(options)
result = subprocess.run(cmd, capture_output=True, text=True)
if result.returncode != 0:
raise RuntimeError(f"Export failed: {result.stderr}")
# Output file is same name with .xlsx extension
output_file = rvt_path.with_suffix('.xlsx')
return output_file
def batch_convert(self, folder: str, mode: str = "standard",
pattern: str = "*.rvt") -> List[Path]:
"""Convert all Revit files in folder."""
folder_path = Path(folder)
converted = []
for rvt_file in folder_path.glob(pattern):
try:
output = self.convert(str(rvt_file), mode)
converted.append(output)
print(f"Converted: {rvt_file.name}")
except Exception as e:
print(f"Failed: {rvt_file.name} - {e}")
return converted
def read_elements(self, xlsx_file: str) -> pd.DataFrame:
"""Read converted Excel as DataFrame."""
return pd.read_excel(xlsx_file, sheet_name="Elements")
def get_quantities(self, xlsx_file: str,
group_by: str = "Category") -> pd.DataFrame:
"""Get quantity summary grouped by category."""
df = self.read_elements(xlsx_file)
# Group and count
summary = df.groupby(group_by).agg({
'ElementId': 'count',
'Area': 'sum',
'Volume': 'sum'
}).reset_index()
summary.columns = [group_by, 'Count', 'Total_Area', 'Total_Volume']
return summaryOutput Structure
输出结构
Excel Sheets
Excel工作表
| Sheet | Content |
|---|---|
| Elements | All BIM elements with properties |
| Categories | Element categories summary |
| Levels | Building levels |
| Materials | Material definitions |
| Parameters | Shared parameters |
| 工作表 | 内容 |
|---|---|
| Elements | 所有带属性的BIM构件 |
| Categories | 构件类别汇总 |
| Levels | 建筑楼层 |
| Materials | 材质定义 |
| Parameters | 共享参数 |
Element Columns
构件列
| Column | Type | Description |
|---|---|---|
| ElementId | int | Unique Revit ID |
| Category | string | Element category |
| Family | string | Family name |
| Type | string | Type name |
| Level | string | Associated level |
| Area | float | Surface area (m²) |
| Volume | float | Volume (m³) |
| BBox_MinX/Y/Z | float | Bounding box min |
| BBox_MaxX/Y/Z | float | Bounding box max |
| 列名 | 类型 | 描述 |
|---|---|---|
| ElementId | 整数 | 唯一Revit ID |
| Category | 字符串 | 构件类别 |
| Family | 字符串 | 族名称 |
| Type | 字符串 | 类型名称 |
| Level | 字符串 | 关联楼层 |
| Area | 浮点数 | 表面积(平方米) |
| Volume | 浮点数 | 体积(立方米) |
| BBox_MinX/Y/Z | 浮点数 | Bounding box最小值 |
| BBox_MaxX/Y/Z | 浮点数 | Bounding box最大值 |
Usage Example
使用示例
python
undefinedpython
undefinedInitialize exporter
Initialize exporter
exporter = RevitExporter("C:/Tools/RvtExporter.exe")
exporter = RevitExporter("C:/Tools/RvtExporter.exe")
Convert single file
Convert single file
xlsx = exporter.convert("C:/Projects/Office.rvt", "complete", ["bbox", "rooms"])
xlsx = exporter.convert("C:/Projects/Office.rvt", "complete", ["bbox", "rooms"])
Read and analyze
Read and analyze
df = exporter.read_elements(str(xlsx))
print(f"Total elements: {len(df)}")
df = exporter.read_elements(str(xlsx))
print(f"Total elements: {len(df)}")
Quantity summary
Quantity summary
quantities = exporter.get_quantities(str(xlsx))
print(quantities)
quantities = exporter.get_quantities(str(xlsx))
print(quantities)
Export to CSV for further processing
Export to CSV for further processing
df.to_csv("elements.csv", index=False)
undefineddf.to_csv("elements.csv", index=False)
undefinedIntegration with DDC Pipeline
与DDC流水线集成
python
undefinedpython
undefinedFull pipeline: Revit → Excel → Cost Estimate
Full pipeline: Revit → Excel → Cost Estimate
from semantic_search import CWICRSemanticSearch
from semantic_search import CWICRSemanticSearch
1. Convert Revit
1. Convert Revit
exporter = RevitExporter()
xlsx = exporter.convert("project.rvt", "complete", ["bbox"])
exporter = RevitExporter()
xlsx = exporter.convert("project.rvt", "complete", ["bbox"])
2. Extract quantities
2. Extract quantities
df = exporter.read_elements(str(xlsx))
quantities = df.groupby('Category')['Volume'].sum().to_dict()
df = exporter.read_elements(str(xlsx))
quantities = df.groupby('Category')['Volume'].sum().to_dict()
3. Search CWICR for pricing
3. Search CWICR for pricing
search = CWICRSemanticSearch()
costs = {}
for category, volume in quantities.items():
results = search.search_work_items(category, limit=5)
if not results.empty:
avg_price = results['unit_price'].mean()
costs[category] = volume * avg_price
print(f"Total estimate: ${sum(costs.values()):,.2f}")
undefinedsearch = CWICRSemanticSearch()
costs = {}
for category, volume in quantities.items():
results = search.search_work_items(category, limit=5)
if not results.empty:
avg_price = results['unit_price'].mean()
costs[category] = volume * avg_price
print(f"Total estimate: ${sum(costs.values()):,.2f}")
undefinedBest Practices
最佳实践
- Use appropriate mode - for quick analysis,
basicfor full datacomplete - Include bbox - Required for spatial analysis and visualization
- Batch carefully - Large files may take time; process overnight
- Validate output - Check element counts against Revit schedules
- 选择合适的模式 - 用于快速分析,
basic用于完整数据complete - 包含bbox - 空间分析和可视化必需
- 谨慎批量处理 - 大文件可能耗时,建议夜间处理
- 验证输出 - 对照Revit明细表检查构件数量
Resources
资源
- GitHub: cad2data Pipeline
- Download: See repository releases for RvtExporter.exe
- GitHub: cad2data Pipeline
- 下载: 查看仓库发布版本获取RvtExporter.exe