BIM Validation Pipeline
Overview
Based on DDC methodology (Chapter 4.3), this skill provides automated BIM data validation pipelines. Validate BIM models against Information Delivery Specification (IDS), Level of Development (LOD) requirements, and project standards.
Book Reference: "Автоматический ETL конвейер для валидации данных" / "Automated ETL Pipeline for Data Validation"
"Автоматизированная валидация BIM-данных позволяет выявлять ошибки на ранних стадиях и обеспечивать соответствие требованиям BEP." — DDC Book, Chapter 4.3
Quick Start
import ifcopenshell
import pandas as pd
# Load IFC model
ifc_model = ifcopenshell.open("model.ifc")
# Quick validation checks
walls = ifc_model.by_type("IfcWall")
print(f"Total walls: {len(walls)}")
# Check for required properties
issues = []
for wall in walls:
# Check if wall has material
if not wall.HasAssociations:
issues.append(f"Wall {wall.GlobalId}: No material assigned")
print(f"Issues found: {len(issues)}")
BIM Validation Framework
Core Validator Class
import ifcopenshell
import ifcopenshell.util.element as element_util
import pandas as pd
from dataclasses import dataclass
from typing import List, Dict, Optional
from enum import Enum
class Severity(Enum):
ERROR = "error"
WARNING = "warning"
INFO = "info"
@dataclass
class ValidationIssue:
element_id: str
element_type: str
rule_id: str
severity: Severity
message: str
location: Optional[str] = None
class BIMValidator:
"""Comprehensive BIM model validator"""
def __init__(self, ifc_path: str):
self.model = ifcopenshell.open(ifc_path)
self.issues: List[ValidationIssue] = []
self.stats = {}
def validate_all(self):
"""Run all validation checks"""
self.validate_geometry()
self.validate_properties()
self.validate_relationships()
self.validate_naming()
self.validate_classification()
return self.get_report()
def validate_geometry(self):
"""Check geometry validity"""
elements_with_geometry = [
e for e in self.model.by_type("IfcProduct")
if e.Representation
]
for element in elements_with_geometry:
# Check for zero volume
try:
settings = ifcopenshell.geom.settings()
shape = ifcopenshell.geom.create_shape(settings, element)
# Volume check would go here
except:
self.issues.append(ValidationIssue(
element_id=element.GlobalId,
element_type=element.is_a(),
rule_id="GEO-001",
severity=Severity.ERROR,
message="Invalid or missing geometry"
))
self.stats['elements_with_geometry'] = len(elements_with_geometry)
def validate_properties(self, required_psets: Dict[str, List[str]] = None):
"""Check required property sets and properties"""
if required_psets is None:
required_psets = {
'IfcWall': ['Pset_WallCommon', 'BaseQuantities'],
'IfcSlab': ['Pset_SlabCommon', 'BaseQuantities'],
'IfcColumn': ['Pset_ColumnCommon', 'BaseQuantities'],
'IfcBeam': ['Pset_BeamCommon', 'BaseQuantities']
}
for ifc_type, psets in required_psets.items():
elements = self.model.by_type(ifc_type)
for element in elements:
element_psets = element_util.get_psets(element)
for required_pset in psets:
if required_pset not in element_psets:
self.issues.append(ValidationIssue(
element_id=element.GlobalId,
element_type=ifc_type,
rule_id="PROP-001",
severity=Severity.WARNING,
message=f"Missing PropertySet: {required_pset}"
))
def validate_relationships(self):
"""Check spatial containment and relationships"""
products = self.model.by_type("IfcProduct")
for product in products:
# Check spatial containment
if hasattr(product, 'ContainedInStructure'):
if not product.ContainedInStructure:
self.issues.append(ValidationIssue(
element_id=product.GlobalId,
element_type=product.is_a(),
rule_id="REL-001",
severity=Severity.WARNING,
message="Element not assigned to building storey"
))
# Check material assignment
if hasattr(product, 'HasAssociations'):
has_material = any(
rel.is_a('IfcRelAssociatesMaterial')
for rel in (product.HasAssociations or [])
)
if not has_material and product.is_a() in ['IfcWall', 'IfcSlab', 'IfcColumn']:
self.issues.append(ValidationIssue(
element_id=product.GlobalId,
element_type=product.is_a(),
rule_id="MAT-001",
severity=Severity.WARNING,
message="No material assigned"
))
def validate_naming(self, patterns: Dict[str, str] = None):
"""Validate element naming conventions"""
import re
if patterns is None:
patterns = {
'IfcBuildingStorey': r'^(Level|L|Floor|Уровень)\s*[-]?\d+',
'IfcWall': r'^W[-_]?\d{3,}|^Wall[-_]',
'IfcColumn': r'^C[-_]?\d{3,}|^Column[-_]',
'IfcSpace': r'^Room[-_]|^Space[-_]'
}
for ifc_type, pattern in patterns.items():
elements = self.model.by_type(ifc_type)
for element in elements:
name = element.Name or ""
if not re.match(pattern, name, re.IGNORECASE):
self.issues.append(ValidationIssue(
element_id=element.GlobalId,
element_type=ifc_type,
rule_id="NAME-001",
severity=Severity.INFO,
message=f"Name '{name}' doesn't match convention"
))
def validate_classification(self, required_systems: List[str] = None):
"""Check classification system assignments"""
if required_systems is None:
required_systems = ['Uniclass', 'OmniClass', 'Uniformat']
elements = self.model.by_type("IfcProduct")
for element in elements:
if hasattr(element, 'HasAssociations'):
has_classification = any(
rel.is_a('IfcRelAssociatesClassification')
for rel in (element.HasAssociations or [])
)
if not has_classification:
self.issues.append(ValidationIssue(
element_id=element.GlobalId,
element_type=element.is_a(),
rule_id="CLASS-001",
severity=Severity.INFO,
message="No classification assigned"
))
def get_report(self):
"""Generate validation report"""
by_severity = {s: [] for s in Severity}
by_type = {}
by_rule = {}
for issue in self.issues:
by_severity[issue.severity].append(issue)
if issue.element_type not in by_type:
by_type[issue.element_type] = []
by_type[issue.element_type].append(issue)
if issue.rule_id not in by_rule:
by_rule[issue.rule_id] = []
by_rule[issue.rule_id].append(issue)