fix(task-19): a .dxf template really reaches the live seat; the fallback dimvars land on Standard

Documents.Add(<file>) accepts only a genuine DWT. Measured on AutoCAD 2026:
Add(templates/iso_a3_pid.dxf) returned the default acadiso drawing (layers
['0'], Layout1/Layout2) exactly as Add() and Add(<missing.dwt>) did, so
drawing_new(template=<bundled name>) reported ok:true with source
'bundled_dxf' over a blank document, and the explicit .dxf path route was
just as blank. ComBackend.drawing_new now converts any non-.dwt template
through AutoCAD itself (Documents.Open read-only -> SaveAs ac2018_Template,
older constants tried next -> Close(False)), caches the .dwt in the temp
folder keyed on path/size/mtime, hands Add the .dwt, and refuses a missing
template file instead of letting Add default silently. The tool result
carries template.dwt / template.dwt_cached. Re-measured end to end through
server.drawing_new on the real ComBackend: ansi_b_mech -> 11 layers, tab B,
DIMTAD 0 / DIMTIH 1 / DIMEXO 1.5; iso_a3_pid -> 17 layers, tab A3, second
call reuses the cached .dwt (0.8 s conversion once). Fake-ActiveX tests pin
the call shape and that the conversion document never stays open.

Headlessly the build's fallback wrote spec 4.1 only as header DIM variables,
and the renderer folds six of them, so DIMTAD/TIH/TOH/EXE/EXO/GAP/LUNIT/LWD
were a no-op: ansi_b_mech dimensioned with ISO text placement while
system_get_variable and AutoCAD said ANSI. The fallback now also stores each
value on the Standard dimstyle; the five DXFs are rebuilt (--check passes)
and a test reads the effective values off a DIMENSION drawn from each
template and asserts header and style agree.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FKFStjEFzpGyLq5bMpWxTd
This commit is contained in:
Umut CAN
2026-09-21 22:31:44 +03:00
co-authored by Claude Opus 5
parent a76d9e08a3
commit 17f7228fd6
10 changed files with 354 additions and 57 deletions
+7 -4
View File
@@ -158,10 +158,13 @@ def resolve_template(name_or_path: str, engine: str) -> tuple[str, str]:
A catalogue name resolves to ``templates/<name>.dxf`` (headless) or
``templates/<name>.dwt`` (live), falling back to the DXF with
``source="bundled_dxf"`` when the ``.dwt`` twin is missing. Anything with a
path separator or a ``.dwt``/``.dxf`` suffix is a path (``source="path"``,
not checked here). A bare word that is not in the catalogue is refused
with the catalogue names.
``source="bundled_dxf"`` when the ``.dwt`` twin is missing — the live
engine then converts that DXF into a real ``.dwt`` itself before
``Documents.Add`` (``ComBackend.drawing_new``), because AutoCAD ignores a
DXF handed to ``Add`` and silently returns the default drawing. Anything
with a path separator or a ``.dwt``/``.dxf`` suffix is a path
(``source="path"``, not checked here). A bare word that is not in the
catalogue is refused with the catalogue names.
"""
raw = str(name_or_path or "").strip()
if not raw: