At a glance
| Hand-written code | 5,703 lines in 14 files |
| Legacy drawings scraped and sorted | 3,706 DWGs (6.8 GB) |
| Single detail sheets produced | 12,334 |
| Entities extracted to JSON | ~2.89 million, from 3,368 unique detail sheets |
| Existing dimensions captured (future training labels) | ~84,000 |
| Parallel throughput | ~435 drawings / hour on 8 AutoCAD workers, ~92 % success |
Lines of code
| Language | Lines | Files | Role |
|---|---|---|---|
| C# | 1,837 | 2 | Drawing classifier and detail splitter (AutoCAD COM); scanner commands |
| PowerShell | 1,888 | 8 | Job runner, queue watcher, parallel worker pool |
| Python | 1,257 | 2 | Document-system scraper; earlier pywin32 version of the splitter |
| AutoLISP | 599 | 1 | In-AutoCAD entity extractor |
| HTML | 122 | 1 | Download helper page |
| Total | 5,703 | 14 |
Not counted: an older duplicate copy of the splitter, saved web pages and the browser profile used by the scraper.
The problem
Dimensioning 2D die-detail drawings is repetitive, standards-driven work that eats a large share of a die designer's time. The end goal is an AutoCAD plugin that proposes production-ready dimensions on a part drawing. A model would decide what to dimension, CAD logic would decide where to place it, and the designer would accept or reject each suggestion.
Any model needs training data first. The company already had that data, in years of legacy drawings, but locked inside multi-sheet DWG files in a web-based document control system. This project builds the pipeline that gets the data out.
document control system ──► Scraper ──► Classifier + Splitter ──► Entity Extractor ──► JSONL dataset
(web, Selenium) 3,706 DWGs 12,334 detail sheets 2.89 M entities 84 K dimensionsWhat I built
1. Scraper (Python + Selenium)
- Attaches to a Chrome session started with remote debugging.
- Walks the document system's folder tree depth-first, page by page, and downloads every DWG.
- Has a dry-run mode for checking what it would fetch before it downloads anything.
2. Drawing classifier and detail splitter (C#, AutoCAD COM automation)
A ~1,650-line console app that drives AutoCAD headlessly.
- Classification: decides whether a drawing is a company die drawing by looking for the standard A–E size title blocks. It checks title-block attributes and text, paper-space layouts, and a count of title blocks in model space. Drawings that fail are set aside. Of 3,706 downloaded drawings, 653 qualified.
- Splitting: for each title block, takes its bounding box grown by 1 %, selects everything that crosses it, and writes the selection out as its own DWG (
WBlock). If that selection comes back empty it falls back to a window selection, then to selection by handle. - Reliability: COM retries with backoff, a COM message filter for "application busy" errors, a checkpoint file so a crashed run resumes where it stopped, and one log per file.
3. Entity extractor (AutoLISP inside AutoCAD)
- Writes one JSON line per model-space entity, in a fixed order so the output is reproducible.
- Each record has an ID, type, layer, handle, bounding box and geometry.
- Captures lines, circles, arcs, polylines (vertices and bulges), text, MText, block references, leaders, and every dimension type with its measurement, override text, text position and dimension-line point.
- JSON escaping and parsing are written by hand in LISP, which has no JSON library.
- Output is checked against versioned JSON Schemas for entity records, dump files, jobs and results.
4. Orchestration bridge (PowerShell)
- File-based job protocol: a job JSON goes in, and a result sidecar plus an entity JSONL file come out. Finished jobs move to
processed/orfailed/, and every run writes a summary. - Parallel worker pool: runs several AutoCAD instances at once, each pinned to its own CPU cores, with per-job timeouts and live progress.
- Runner: starts AutoCAD with a generated script and sets AutoCAD's trusted paths so files load without prompts.
- Built for an AI coding agent: an agent writes the jobs and LISP, AutoCAD runs them unattended, and the agent reads the structured results back.
Results
- Sort and split: 3,706 source drawings in, 12,334 detail sheets out. All 8 workers exited cleanly.
- Extraction: 3,103 detail sheets processed in about 7.1 hours on 8 workers (~435 per hour). 2,865 completed, 234 failed and 4 timed out, so about 92 % succeeded.
- Dataset: ~2.89 million entity records, including 1.46 M lines, 486 K text entities, 243 K arcs, 216 K block references, 124 K polylines and 85 K circles.
- Training labels: ~84,000 existing dimensions written by human designers: 43,182 rotated, 36,462 ordinate, 1,971 angular, 1,292 radial, 832 diametric and 307 aligned. These are the labels the model will learn from.
Status and next steps
- Built and run at scale: scraper, classifier and splitter, LISP extractor, parallel bridge and schemas.
- In progress: extracting the full set of 11,831 detail sheets (about 26 % done).
- Planned, not built:
- matching each dimension to the geometry it measures;
- topology and graph features;
- a rule-based baseline and an ML ranker;
- the AutoCAD plugin with collision-aware placement;
- a feedback loop that retrains on accepted and rejected suggestions.
- No model has been trained yet, so there are no accuracy figures.