Drawing Takeoff
Contractors get flattened PDF drawings, not the BIM model. The structured data that was in the model gets thrown away on export — but a construction PDF still carries a hidden vector text layer with the real tags, schedules and dimensions. This skill reads that layer once, builds a SQLite database, and then answers questions from the database.
Why this beats re-reading the PDF each time
- Reading raw drawing images into the prompt is the most expensive path and the least reliable — the model guesses from pixels and mis-weights detail buried in a huge context.
- Reading the vector text is cheaper and more accurate.
- Querying a finished database is cheapest of all and deterministic.
The reliability rule (do not skip)
Not every question is equally trustworthy. Say so, every time.
| Question type | How it's answered | Confidence |
|---|---|---|
| Counting objects (columns, doors, fixtures) | reads schedule rows / tag callouts from the text layer | high (schedule) / medium (tag) |
Dimensions printed on the sheet (205'-6") | reads the number the designer wrote | high |
| Measuring an unlabeled distance | scaled from pixels via the scale bar | low — must pass a sanity check |
Every measurement in the DB is tagged confidence and sanity_status. A run
longer than the whole building footprint is flagged automatically. When you hand
a number to the user, state its confidence and whether it passed sanity checks.
Workflow
Scripts live in scripts/. Run with the py launcher on Windows (or python3).
-
Build the database once from the PDF (fast, ~seconds/100 pages):
py scripts/takeoff.py build "SET.pdf" --db set.dbReads the vector text of every sheet: sheet numbers, disciplines, scales, printed dimensions (high confidence), and tag-callout counts (medium). It also writes
drawing.md— a one-page index of every sheet and what's on it that sits on top of the database. Readdrawing.mdfirst on any question: it tells you which sheet holds the answer so you query straight to it. -
Add high-confidence schedule counts (opt-in second pass). Table detection is slow on large-format sheets (~30s/page), so point it only at the schedule sheets — either
--auto(every page whose text says "schedule") or a page list you already know:py scripts/takeoff.py schedules "SET.pdf" --db set.db --pages 12,56,67 py scripts/takeoff.py schedules "SET.pdf" --db set.db --autoEach schedule row becomes one high-confidence object (e.g. 147 doors from the door schedule, with their marks).
-
Answer questions from the DB (cheap, repeatable):
py scripts/takeoff.py query count # all object types py scripts/takeoff.py query count --type door # one type, by confidence py scripts/takeoff.py query list --type door # each object + its attributes + sheet py scripts/takeoff.py query sheets # sheet index + scale + discipline py scripts/takeoff.py query dims --sheet A-101 # dimensions on a sheet py scripts/takeoff.py query flags # measurements that failed sanity py scripts/takeoff.py query sql "SELECT ..." # any read-only SQLdrawing.mdis regenerated bybuildandschedules; recreate it any time withpy scripts/takeoff.py summary --db set.db. -
Re-run cross-checks after tuning:
py scripts/takeoff.py check --db set.db
How to use this as Claude
- When asked a quantity/dimension question about a drawing set, check whether a
.dbalready exists. If yes, readdrawing.mdfirst to locate the right sheet, thenquerythe database — do not re-read the PDF. - If no DB exists,
buildone first (and runschedulesfor counts), then query. - For a count, report the number and its confidence and source (schedule vs tag). For a dimension, report the number, that it was read from an annotation (high) or scaled (low), and its sanity status.
- Only open the raw PDF page when the DB genuinely can't answer (e.g. a visual detail with no text). Pull the single page, not the whole set.
Tuning per client (important, not fluff)
Tagging conventions differ between drawing sets. Object counting from plan
callouts is only as good as the regexes in scripts/patterns.py:
TAG_PATTERNS— how doors/windows/columns/grids are labelled on plans.SCHEDULE_KEYWORDS— header words that mark a table as a schedule.DISCIPLINE_MAP/ scale patterns — sheet-number and scale conventions.
Schedule row-counts and printed dimensions are reliable across sets. Tag-based
plan counts depend entirely on TAG_PATTERNS matching your set's labels, so
spot-check them against one sheet before trusting them on a bid.
See SETUP.md for install and a worked example.


