---
estimated_steps: 1
estimated_files: 3
skills_used: []
---

# T01: Extend engine DXF generator with unit/scale support and wire through API

The engine's `generate_dxf()` currently produces DXF files with raw pixel coordinates and no unit metadata. This task extends it to accept `units` ('inches'|'mm') and `scale_factor` parameters, sets the `$INSUNITS` and `$MEASUREMENT` DXF headers, applies `scale_factor` to all polyline coordinates, and adds optional `layer_map` support. The `/engine/simplify` endpoint is extended with optional `units` and `scale_factor` Form params that pass through to the DXF generator via `_format_response()`. Tests verify a known-size artboard (384×576 px = 4×6 inches at 96 PPI) produces DXF coordinates spanning 0–4 × 0–6 with correct `$INSUNITS=1`.

## Inputs

- ``engine/output/dxf.py` — existing DXF generator that accepts PostProcessResult`
- ``engine/api/routes.py` — existing `/engine/simplify` endpoint and `_format_response()` helper`
- ``engine/tests/test_output.py` — existing DXF/SVG/JSON output tests`
- ``engine/pipeline/postprocess.py` — PostProcessResult and PathInfo types consumed by DXF generator`

## Expected Output

- ``engine/output/dxf.py` — extended with units, scale_factor, layer_map params; sets $INSUNITS/$MEASUREMENT headers; applies scale to coordinates`
- ``engine/api/routes.py` — /engine/simplify accepts optional units and scale_factor Form params; _format_response passes them to generate_dxf`
- ``engine/tests/test_output.py` — new tests: scale_factor converts pixel coords to real-world coords, $INSUNITS header set correctly for inches/mm, layer_map assigns paths to named layers`

## Verification

cd engine && .venv/bin/python -m pytest tests/test_output.py -v -W ignore::DeprecationWarning
