batch-cad-converter
Batch convert multiple CAD/BIM files (Revit, IFC, DWG, DGN) with progress tracking, error handling, and consolidated reporting.
git clone --depth 1 https://github.com/datadrivenconstruction/DDC_Skills_for_AI_Agents_in_Construction /tmp/batch-cad-converter && cp -r /tmp/batch-cad-converter/1_DDC_Toolkit/CAD-Converters/batch-cad-converter ~/.claude/skills/batch-cad-converterSKILL.md
# Batch CAD/BIM Converter
## Business Case
### Problem Statement
Large projects and archives contain hundreds or thousands of CAD/BIM files:
- Manual conversion is tedious and error-prone
- Different formats require different converters
- Progress tracking is needed for long operations
- Error handling is critical for large batches
### Solution
Unified batch converter handling all supported formats with progress tracking, error recovery, and consolidated reporting.
### Business Value
- **Multi-format** - Revit, IFC, DWG, DGN in one workflow
- **Error recovery** - Continue on failures
- **Progress tracking** - Monitor large batches
- **Reporting** - Consolidated conversion results
## Python Implementation
```python
import subprocess
from pathlib import Path
from typing import List, Optional, Dict, Any, Callable
from dataclasses import dataclass, field
from datetime import datetime
import time
import json
from enum import Enum
from concurrent.futures import ThreadPoolExecutor, as_completed
class CADFormat(Enum):
"""Supported CAD/BIM formats."""
REVIT = (".rvt", ".rfa")
IFC = (".ifc",)
DWG = (".dwg",)
DGN = (".dgn",)
class ConversionStatus(Enum):
"""Status of conversion operation."""
PENDING = "pending"
CONVERTING = "converting"
SUCCESS = "success"
FAILED = "failed"
SKIPPED = "skipped"
@dataclass
class ConversionResult:
"""Result of single file conversion."""
input_file: str
output_file: Optional[str]
format: str
status: ConversionStatus
start_time: datetime
end_time: Optional[datetime]
duration_seconds: float
error_message: Optional[str] = None
file_size_kb: float = 0
@dataclass
class BatchResult:
"""Result of batch conversion."""
total_files: int
successful: int
failed: int
skipped: int
total_duration: float
results: List[ConversionResult]
start_time: datetime
end_time: datetime
class BatchCADConverter:
"""Batch convert multiple CAD/BIM files."""
# Default converter paths
DEFAULT_CONVERTERS = {
'revit': 'RvtExporter.exe',
'ifc': 'IfcExporter.exe',
'dwg': 'DwgExporter.exe',
'dgn': 'DgnExporter.exe'
}
def __init__(self, converter_dir: str = ".",
converters: Dict[str, str] = None):
self.converter_dir = Path(converter_dir)
self.converters = converters or self.DEFAULT_CONVERTERS
self.results: List[ConversionResult] = []
self.progress_callback: Optional[Callable] = None
def set_progress_callback(self, callback: Callable[[int, int, str], None]):
"""Set callback for progress updates."""
self.progress_callback = callback
def _get_format(self, file_path: Path) -> Optional[str]:
"""Detect CAD format from extension."""
ext = file_path.suffix.lower()
for format_name, extensions in [
('revit', ('.rvt', '.rfa')),
('ifc', ('.ifc',)),
('dwg', ('.dwg',)),
('dgn', ('.dgn',))
]:
if ext in extensions:
return format_name
return None
def _get_converter(self, format_name: str) -> Optional[Path]:
"""Get converter path for format."""
if format_name not in self.converters:
return None
converter = self.converter_dir / self.converters[format_name]
if converter.exists():
return converter
# Try in system PATH
return Path(self.converters[format_name])
def convert_file(self, input_file: str,
output_dir: Optional[str] = None,
options: List[str] = None) -> ConversionResult:
"""Convert single file."""
input_path = Path(input_file)
start_time = datetime.now()
# Detect format
format_name = self._get_format(input_path)
if not format_name:
return ConversionResult(
input_file=input_file,
output_file=None,
format='unknown',
status=ConversionStatus.SKIPPED,
start_time=start_time,
end_time=datetime.now(),
duration_seconds=0,
error_message="Unsupported format"
)
# Get converter
converter = self._get_converter(format_name)
if not converter:
return ConversionResult(
input_file=input_file,
output_file=None,
format=format_name,
status=ConversionStatus.FAILED,
start_time=start_time,
end_time=datetime.now(),
duration_seconds=0,
error_message=f"Converter not found for {format_name}"
)
# Build command
cmd = [str(converter), str(input_path)]
if options:
cmd.extend(options)
# Execute
try:
result = subprocess.run(cmd, capture_output=True, text=True, timeout=3600)
end_time = datetime.now()
duration = (end_time - start_time).total_seconds()
# Determine output file
output_file = input_path.with_suffix('.xlsx')
if output_dir:
output_file = Path(output_dir) / output_file.name
if result.returncode == 0 and output_file.exists():
return ConversionResult(
input_file=input_file,
output_file=str(output_file),
format=format_name,
status=ConversionStatus.SUCCESS,
start_time=start_time,
end_time=end_time,
duration_seconds=duration,
file_size_kb=output_file.stat().st_size / 1024
)
else:
return ConversionResult(
input_file=input_file,
output_file=None,
format=Generate automated daily progress reports from site data. Track work completed, labor hours, equipment usage, and weather conditions.
Analyze labor productivity from site data. Compare planned vs actual, identify trends, benchmark against industry standards.
Create interactive KPI dashboards for construction projects. Track schedule, cost, quality, and safety metrics in real-time.
Detect and analyze geometric clashes in BIM models. Identify MEP, structural, and architectural conflicts before construction.
Classify BIM elements using AI and standard classification systems. Map elements to UniFormat, MasterFormat, OmniClass, and CWICR codes.
Generate comprehensive BIM model validation reports. Check data quality, completeness, and compliance with standards.
Calculate CO2 emissions and carbon footprint from BIM model data. Analyze embodied carbon by material, element, and building system.
Extract quantities from IFC/Revit models for quantity takeoff. Uses DDC converters to get element counts, areas, volumes, lengths with grouping and reporting.