---
id: T01
parent: S01
milestone: M003
provides: []
requires: []
affects: []
key_files: ["engine/output/dxf.py", "engine/api/routes.py", "engine/tests/test_output.py"]
key_decisions: ["DXF $INSUNITS codes: inches=1, mm=4; $MEASUREMENT: inches=0, mm=1", "layer_map is index-based (dict[int, str]) with island auto-layer fallback", "scale_factor applied uniformly to all (x, y) coords; caller computes the value"]
patterns_established: []
drill_down_paths: []
observability_surfaces: []
duration: ""
verification_result: "Ran pytest tests/test_output.py: 36/36 passed (25 existing + 11 new). Ran full engine suite: 207/207 passed. Scale conversion tests verify 384×576 px artboard produces 4×6 inch and 101.6×152.4 mm coordinates. $INSUNITS header tests confirm inches=1, mm=4. Layer_map tests confirm custom layer assignment and island layer preservation."
completed_at: 2026-03-26T06:16:59.178Z
blocker_discovered: false
---

# T01: Extended generate_dxf() with units/scale_factor/layer_map params and wired units+scale_factor through /engine/simplify API endpoint

> Extended generate_dxf() with units/scale_factor/layer_map params and wired units+scale_factor through /engine/simplify API endpoint

## What Happened
---
id: T01
parent: S01
milestone: M003
key_files:
  - engine/output/dxf.py
  - engine/api/routes.py
  - engine/tests/test_output.py
key_decisions:
  - DXF $INSUNITS codes: inches=1, mm=4; $MEASUREMENT: inches=0, mm=1
  - layer_map is index-based (dict[int, str]) with island auto-layer fallback
  - scale_factor applied uniformly to all (x, y) coords; caller computes the value
duration: ""
verification_result: passed
completed_at: 2026-03-26T06:16:59.197Z
blocker_discovered: false
---

# T01: Extended generate_dxf() with units/scale_factor/layer_map params and wired units+scale_factor through /engine/simplify API endpoint

**Extended generate_dxf() with units/scale_factor/layer_map params and wired units+scale_factor through /engine/simplify API endpoint**

## What Happened

Extended generate_dxf() with three keyword-only args (units, scale_factor, layer_map), set $INSUNITS/$MEASUREMENT DXF headers for inches/mm, applied scale_factor to all polyline coordinates, added layer_map for custom DXF layer assignment. Wired units and scale_factor through the /engine/simplify API endpoint via _format_response(). Added 11 new tests covering scale conversion (384x576 px → 4x6 inches, 101.6x152.4 mm), DXF header correctness, layer mapping, and combined feature usage.

## Verification

Ran pytest tests/test_output.py: 36/36 passed (25 existing + 11 new). Ran full engine suite: 207/207 passed. Scale conversion tests verify 384×576 px artboard produces 4×6 inch and 101.6×152.4 mm coordinates. $INSUNITS header tests confirm inches=1, mm=4. Layer_map tests confirm custom layer assignment and island layer preservation.

## Verification Evidence

| # | Command | Exit Code | Verdict | Duration |
|---|---------|-----------|---------|----------|
| 1 | `cd engine && .venv/bin/python -m pytest tests/test_output.py -v -W ignore::DeprecationWarning` | 0 | ✅ pass | 390ms |
| 2 | `cd engine && .venv/bin/python -m pytest tests/ -v -W ignore::DeprecationWarning` | 0 | ✅ pass | 1060ms |


## Deviations

Adjusted test_no_units_omits_insunits_header: ezdxf R2000 defaults $INSUNITS to 6 (meters) not 0 (unitless) as plan assumed.

## Known Issues

None.

## Files Created/Modified

- `engine/output/dxf.py`
- `engine/api/routes.py`
- `engine/tests/test_output.py`


## Deviations
Adjusted test_no_units_omits_insunits_header: ezdxf R2000 defaults $INSUNITS to 6 (meters) not 0 (unitless) as plan assumed.

## Known Issues
None.
