Python toolkit for asphalt paving estimating — turn plan PDFs, CAD drawings, specifications, contractor quotes, delivery tickets, supplier prices and site photos into audit-ready estimates for the AsphaltCosts.com calculation engine.
English | 简体中文
Manual asphalt takeoff is slow and error-prone: dimensions live inside PDF plans and CAD drawings, requirements hide in long specification documents, contractor bids are formatted differently on every sheet, and delivery tickets rarely match the estimate. This project replaces the copy-paste-and-spreadsheet workflow with a deterministic, evidence-backed desktop pipeline for asphalt and paving estimators, project managers, foremen and homeowners.
Every script runs a standard lifecycle — DISCOVER → INGEST → EXTRACT → NORMALIZE → VALIDATE → CALCULATE/CLASSIFY → OUTPUT → AUDIT — and every important value carries {value, unit, source_file, source_page, source_region, method, confidence, state, verified}.
- Quantity takeoff from plan PDFs and CAD/DXF drawings — area, thickness, tons, order tons and truckloads with per-region evidence
- Specification checking — structured requirements and SPEC-vs-ADDENDUM / PLAN-vs-SPEC / SPEC-vs-BID conflict detection
-
Contractor quote comparison — normalized side-by-side bids with
$/SF, $ /ton and scope flags (no ranking) - Delivery ticket reconciliation — delivered vs estimated tons from CSV / PDF / image tickets with gross−tare validation
- Supplier price normalization — evidence-backed material price dataset with basis and validity windows
- Weather & compaction planning — HMA cooling/compaction window from a documented lumped thermal model
- Field photo screening — potholes, cracking, rutting and surface anomaly detection for QA
- Audit-ready estimate reports — JSON / Markdown / XLSX / PDF with source and calculation registers
- Human-in-the-loop — low-confidence values and conflicts land in a review queue, never silently fixed
| ID | Script | Primary user | Main input | Main output |
|---|---|---|---|---|
| S01 | scripts/s01_project_workspace.py |
estimator / PM / foreman | files + project metadata | normalized project workspace (project.json, manifest, source index) |
| S02 | scripts/s02_pdf_plan_takeoff.py |
estimator / PM | civil/paving plan PDFs | paving takeoff table + engine quantities |
| S03 | scripts/s03_cad_takeoff.py |
estimator / engineer | DWG (→DXF) / DXF | geometry quantities |
| S04 | scripts/s04_specification_checker.py |
estimator / PM | specification PDFs | structured requirements + conflicts |
| S05 | scripts/s05_quote_comparator.py |
homeowner / PM / estimator | contractor quotes | comparable quote table + flags |
| S06 | scripts/s06_delivery_ticket_reconcile.py |
foreman / PM | ticket PDFs/images/CSV | delivered-vs-estimated reconciliation |
| S07 | scripts/s07_supplier_quote_normalizer.py |
purchaser / estimator | supplier quotes | normalized material price dataset |
| S08 | scripts/s08_weather_compaction_planner.py |
superintendent / foreman | weather + project parameters | paving window analysis (thermal model) |
| S09 | scripts/s09_field_photo_analyzer.py |
foreman / homeowner / PM | site photos | visual condition screening |
| S10 | scripts/s10_estimate_report_builder.py |
estimator / PM | structured project data | audit-ready estimate/report |
- Python 3.12+ (Windows 11 first-class, cross-platform CLI)
- PDF parsing — PyMuPDF-based text / vector / scale-note extraction
- CAD — DXF geometry parsing for takeoff (DWG via conversion)
- AI boundary — deterministic heuristic extractor by default; optional OpenAI-compatible backend (
ADI_AI_API_KEY) for candidate extraction and anomaly explanation only - CLI conventions — every script shares
--project <path> --input <path> --output <path> --format json|csv|md|xlsx|pdf --config <path> --verbose --dry-run - Testing — golden fixture suite (
pytest) with tolerance gates (±0.5% plan areas, <0.1% DXF geometry)
# Python 3.12+ on Windows 11
pip install -r requirements.txt
# 1) Create a normalized project workspace from any mixture of files
python scripts/s01_project_workspace.py --project .\Project01 --input .\Project01\input
# 2) Take off paving quantities from a plan PDF (vector or dimension-derived)
python scripts/s02_pdf_plan_takeoff.py --project .\Project01 --input .\Project01\input\plans\civil-set.pdf
# 3) Pull material quantities through the AsphaltCosts engine
python scripts/s10_estimate_report_builder.py --project .\Project01 --format mdRun any script with --help for its options.
- Standard lifecycle — every script runs
DISCOVER → INGEST → EXTRACT → NORMALIZE → VALIDATE → CALCULATE/CLASSIFY → OUTPUT → AUDIT. - Evidence state machine — every important value moves
EXTRACTED → NORMALIZED → VALIDATED → VERIFIED; it is valid to stop at any earlier state. - AI boundary — AI may extract candidates, map synonyms and explain anomalies; it may never invent dimensions, silently change a source value, replace a deterministic calculator result, or mark a value verified without evidence.
- Human-in-the-loop — low-confidence values, ambiguous scales, conflicts and missing data land in a compact review queue (
review_queue.json/ summary in each report), never a silent fix. - Audit — every run writes
run_id, script, timings, input hashes, engine version, warnings, errors and outputs to<project>/audit/.
Copy config.example.json to config.json (or point --config at your own file). Endpoints, rate limits and AI provider settings load from configuration; the asphaltcosts.api_endpoint field enables direct HTTP calls to the calculation engine when such an endpoint is published — until then the client uses the documented web-engine math as a labeled local mirror (engine_version: asphaltcosts-web-engine/1.0-mirror).
pip install -r requirements.txt
python tools/make_pdf_fixtures.py # golden plan PDFs (needs pymupdf)
python tools/make_photo_fixtures.py # golden photos (needs Pillow)
pytest -qGolden tests cover known plan areas (±0.5%), known DXF geometry (<0.1%), specification extraction, quote comparison, 100-ticket reconciliation, thermal-model direction checks, photo screening and report determinism.
common/ shared thin foundation (units, schemas, provenance, validation,
audit, engine client, AI adapter, CLI, DXF parser, output writers)
scripts/ S01–S10
schemas/ JSON contracts (value envelope, takeoff record, project.json)
fixtures/ golden DXF / quotes / specs / tickets / suppliers / weather
tests/ pytest suite
tools/ fixture generators
skills/ AI-agent skill definitions (SKILL.md per script)
docs/ architecture & per-script specifications
Each business scenario is also published as its own standalone GitHub repository (own README, tests, fixtures, license and its own visible link back to AsphaltCosts.com), rebuilt from this monorepo with python tools/build_subrepos.py:
AsphaltCosts.com — asphalt tonnage, cost, coverage, truckload and paving calculators: area → compacted volume → net tons → order tons (allowance applied once) → truckloads → material cost, with sourced planning defaults (145 lb/ft³ FHWA density, editable allowance and truck capacity).
The web site stays the deterministic calculation layer: tons, volume, coverage, truckloads and material cost come from the AsphaltCosts engine, never from re-implemented desktop math. These scripts solve the tasks that need local files, batch processing, OCR, CAD parsing, project evidence, AI document understanding or local automation — and they feed normalized, validated values into the engine.
⚠️ Planning tool, not engineering design. All outputs are planning estimates. Results must never be presented as "approved to pave" or as an engineering verdict.
- Local files stay local by default; AI upload requires explicit per-run configuration.
- API keys live in environment variables (
ASPHALTCOSTS_API_KEY,ADI_AI_API_KEY) or Windows Credential Manager — never in source code. - File hashes are recorded so every report identifies the exact source version used.
- Never overwrite or delete a source file automatically; derived files live in
working/oroutput/.
MIT — see LICENSE.