Skip to content

From PDF Linework to a 3D Model

The first step in this morning's takeoff was extracting usable information from construction PDFs. Python scripts read the drawings, assemble geometry, and write records that the browser viewer can consume.

Vector drawings and scanned sheets

A vector PDF can contain paths and text with page coordinates. PyMuPDF's page.get_drawings() exposes drawing paths; page.get_text("dict") returns text blocks and their positions. The project uses both. See PyMuPDF's drawing extraction guide and text extraction reference.

A scanned sheet contains pixels instead of recoverable vector linework. It needs a different extraction path, such as image processing, OCR for labels, and reviewed tracing. OCR can read a dimension label; it does not turn the image into correctly scaled construction geometry by itself.

Page coordinates need a construction coordinate system

The project scripts register sheets to a shared model origin and convert drawing coordinates into feet. A useful workflow checks known dimensions and grid intersections after that transformation. Different sheet scales, rotated details, match lines, and enlarged views require separate handling.

Profiles add another complication: horizontal stationing and vertical elevations may use different scales. Matching a profile to the correct plan alignment is part of the work. Extruding every PDF line to an arbitrary height would skip the evidence needed for a takeoff.

Turning paths into objects

The scripts use Shapely to combine linework and assemble polygons. Its operations work in a plane: it can measure areas and lengths, join geometry, and help identify closed boundaries. Elevation must be handled separately. See the Shapely manual.

A closed outline might be a footing, an opening, a symbol, or a title-block detail. Text, sheet context, schedules, and review give the shape its meaning. Small gaps and duplicate edges also need attention before an outline becomes a quantity.

NumPy appears in the coordinate calculations. SciPy's spatial tools help with matching and triangulation; its Delaunay routine creates triangles from points. In this project, sparse PDF elevations support a grade visualization. The viewer explicitly excludes cut/fill quantities and cover checks from that study.

A record worth keeping

Useful model data includes an element ID, dimensions, location, units, scope, source sheet and page, and a note about verification. JSON is the text format connecting those records to the viewer. CSV exports turn selected quantity fields into rows for estimating.

My review sequence is to compare geometry against its source, check a known dimension, inspect overlapping scope, and reconcile modeled quantities with the workbook. An unresolved profile stays unresolved until the evidence supports locating it.

Where AI helps

Astra helped create and revise the scripts and viewer. That compresses the time spent building the workflow and responding to corrections. Repeatable scripts then let the same extraction and calculations run again. The result is much more useful when the model preserves the evidence behind each decision.

Find something.

Search the wiki, writing, apps, and more.

Esc to close · ⌘K / Ctrl K to search

Say hello.

Have a question, an idea, or just want to connect?

hi@masonearl.com
Gmail ↗Outlook ↗

Choose your email service, or try your default email app ↗.

X / @masonearl ↗LinkedIn ↗