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:
co-authored by
Claude Opus 5
parent
a76d9e08a3
commit
17f7228fd6
@@ -11,9 +11,15 @@ what ships.
|
||||
|
||||
Styles: once group S's ``dimstyle_create`` / ``textstyle_create`` are on the
|
||||
backend they are used (ISO-25 / ISOCP, ANSI / ROMANS, set current). Until then
|
||||
the same values (spec §4.1) are written as header DIM variables so the template
|
||||
already dimensions correctly; the final task re-runs this script after the S
|
||||
merge and re-commits the five files.
|
||||
the same values (spec §4.1) are written twice — as header DIM variables, which
|
||||
is what a live seat dimensions with, *and* onto the ``Standard`` dimstyle
|
||||
entry, which is what the headless renderer reads (it never consults the
|
||||
header; ``_with_header_dimvars`` folds six of the variables, so the other
|
||||
eight — DIMTAD, DIMTIH, DIMTOH, DIMEXE, DIMEXO, DIMGAP, DIMLUNIT, DIMLWD/E —
|
||||
were a header-only no-op: measured, ``ansi_b_mech`` dimensioned with ISO text
|
||||
placement headlessly while AutoCAD honoured the header). Both engines now
|
||||
dimension the same template the same way; the final task re-runs this script
|
||||
after the S merge and re-commits the five files.
|
||||
|
||||
``--check`` rebuilds into a temporary folder and compares line by line after
|
||||
masking the values ezdxf cannot keep constant — measured on 2026-09-16, exactly
|
||||
@@ -115,11 +121,14 @@ async def _apply_styles(backend, spec: TemplateSpec) -> dict:
|
||||
)
|
||||
return {"mode": "styles", "dimstyle": dim["name"], "textstyle": text["name"]}
|
||||
applied = {}
|
||||
standard = backend._doc.dimstyles.get("Standard") # what the headless renderer reads
|
||||
for variable, value in _FALLBACK_DIMVARS[spec.dimstyle_preset].items():
|
||||
applied[variable] = (await backend.system_set_variable(variable, value))["ok"]
|
||||
standard.dxf.set(variable.lower(), value)
|
||||
return {
|
||||
"mode": "header_dimvars",
|
||||
"applied": applied,
|
||||
"dimstyle": standard.dxf.name,
|
||||
"pending": "dimstyle_create/textstyle_create not on this backend yet (group S)",
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user