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
+11
View File
@@ -1112,6 +1112,13 @@ async def drawing_new(
`source: "bundled_dxf"` when no `.dwt` twin is committed); a path is used
as given. The result carries `template: {name|path, path, source}`.
On the live engine only a genuine `.dwt` reaches `Documents.Add` —
measured on AutoCAD 2026, `Add(<file.dxf>)` silently returns the default
drawing — so a `.dxf` template (bundled or a path) is first converted
through AutoCAD into a cached `.dwt` and `template.dwt` names it
(`template.dwt_cached` says whether the conversion was reused). The
drawing then really carries the template's layers, tabs and page setup.
Refused before anything is replaced: a bare name that is not in the
catalogue (the message lists the five), a template path that does not
exist, and a path outside the allowed directories. With `bootstrap=True`
@@ -1140,7 +1147,11 @@ async def drawing_new(
await ctx.info(f"Creating new drawing (template={template}, bootstrap={bootstrap})")
raw = await backend.drawing_new(template)
result = dict(raw) if isinstance(raw, dict) else {"result": raw}
converted = result.pop("template_dwt", None)
if template_info is not None:
if converted: # the live engine built a .dwt from the .dxf (see ComBackend.drawing_new)
template_info["dwt"] = converted["path"]
template_info["dwt_cached"] = bool(converted.get("cached"))
result["template"] = template_info
if bootstrap:
try: