IFC Spatial Asset Extraction and Verification Script
Automate the extraction, validation, and database ingestion of BIM structural elements and phase quantities.
Use this template when setting up automated model audit pipelines for commercial construction models. It generates a Python-based processing script that extracts property sets and validates spatial metrics against project schedules.
Role: Principal Construction Systems Integration Engineer with 12+ years optimizing building information modeling pipelines.
Context
- Project Site Identifier: {{project_site_code}}
- Source BIM Format: {{bim_model_format}}
- Property Sets to Parse: {{property_set_names}}
- Active Construction Milestone: {{construction_phase}}
- Tolerance Variance Limit: {{tolerance_threshold}}
- Target Database Destination: {{database_target}}
Task
Generate an executable Python extraction script utilizing open-source BIM libraries to parse spatial asset quantities from building model files, validate them against phase tolerances, and batch-insert structured records into the staging database for construction site progress tracking.
Method
- Initialize project-level configuration, loading connection parameters for {{database_target}} and establishing file references for {{project_site_code}}.
- Parse the target {{bim_model_format}} file using IfcOpenShell or equivalent parser to inspect schema validity and spatial hierarchy.
- Query and filter structural entities matching the requested {{property_set_names}} relevant to {{construction_phase}}.
- Calculate geometric quantities including volumes, surface areas, and boundary coordinates per entity.
- Evaluate extracted measurements against baseline schedules applying the allowed {{tolerance_threshold}}.
- Flag out-of-tolerance elements with explicit variance delta records and severity classifications.
- Format normalized asset records and bulk-insert them into {{database_target}} wrapped in a transactional block.
- Emit an execution summary containing processed entity counts, flagged variances, and runtime benchmarks.
Constraints
- The script MUST handle missing property attributes gracefully by logging warnings rather than terminating execution.
- All database transactions MUST use parameterized queries to prevent injection vulnerabilities.
- External dependencies MUST be restricted to standard Python libraries and IfcOpenShell.
- MUST NOT perform destructive write operations against source BIM model files.
- Error handling MUST write failed element identifiers to a local JSON fallback file.
Output format
Provide the solution in three sequential markdown sections:
- Dependency Prerequisites (pip install commands and minimum version matrix).
- Production Python Script (complete, documented executable script under 150 lines).
- Sample Configuration and Execution Command (CLI invocation example with mock parameters).
Self-review
- Confirm all 6 context variables ({{project_site_code}}, {{bim_model_format}}, {{property_set_names}}, {{construction_phase}}, {{tolerance_threshold}}, {{database_target}}) appear in the script logic.
- Verify error handling covers database connection failure and malformed element trees.
- Ensure script includes inline docstrings explaining core transformation logic.
Explicit role, a named task, and discrete steps the model can follow.
Background, inputs and variables the model needs before it starts.
Hard boundaries — what the model must and must not do.
A named, field-level shape for the response.
Ordered work items that force analysis before an answer.
Length and structure that travel across frontier models.
Signal density — instruction weight without padding.
Documented variables so the scaffold adapts to new inputs.
Quality bar, assumptions and behaviour when inputs are thin.
How much real usage the template has behind it.