fix(task-14): refuse CANNOSCALE on an R12 file headlessly instead of losing it at save
Measured: an R12 (AC1009) document has no OBJECTS section, so ezdxf exports neither AcDbVariableDictionary/DICTIONARYVAR nor the seeded SCALE objects, and drawing_save_as keeps AC1009. `_set_annotation_scale` reported `ok: True, changed 1:1 -> 1:50` and the file reloaded as 1:1 -- the header-only write that vanishes on reload, the class this task exists to remove, and a breach of the backend's own R12 honesty convention (viewport_set_scale / lock). The write is now refused with a ValueError naming R12 and "save as R2000 or newer", after parse_scale (a malformed value is still named as such) and before either dictionary is touched, so a refused call leaves the root dictionary as it found it and drawing_settings still applies the sibling keys (limits / grid / ortho survive R12). The refusal is listed with the others in the contract and server docstrings. Pinned by two tests that save, reopen and read the R12 file back. 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
909bc47e5e
commit
f3ff703144
@@ -6045,6 +6045,18 @@ class EzdxfBackend(AutoCADBackend):
|
||||
|
||||
def _set_annotation_scale(self, doc, value: Any) -> str:
|
||||
name, paper, drawing = parse_scale(value) # refused before any write
|
||||
if self._is_r12():
|
||||
# Measured: an R12 (AC1009) file has no OBJECTS section, so ezdxf
|
||||
# exports neither AcDbVariableDictionary/DICTIONARYVAR nor the
|
||||
# SCALE objects. The in-memory write "succeeded" and reloaded as
|
||||
# 1:1 -- the header-only-write-that-vanishes class again. Refused
|
||||
# here, before either dictionary is created, so a refused call
|
||||
# leaves the root dictionary as it found it.
|
||||
raise ValueError(
|
||||
"CANNOSCALE: R12 has no OBJECTS section, so the annotation scale "
|
||||
"(AcDbVariableDictionary and ACAD_SCALELIST) would be lost on save. "
|
||||
"Save as R2000 or newer first."
|
||||
)
|
||||
self._ensure_scale_entry(doc, name, paper, drawing)
|
||||
vardict = self._variable_dictionary(doc, create=True)
|
||||
entry = vardict.get("CANNOSCALE")
|
||||
|
||||
Reference in New Issue
Block a user