fix(task-1): refuse block_insert of an undefined block before writing
`add_blockref` never checks the name and `add_auto_attribs` skips autofill when `Insert.block()` resolves to None, so a typo'd block name returned a handle whose attribute values were silently dropped and whose dangling INSERT `doc.audit()` later deletes. Check `name in self._doc.blocks` and raise `ValueError` on both the attribute and no-attribute paths, matching the COM engine's `InsertBlock` refusal for an unknown name. 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
be7dfa86d3
commit
6f4bda5028
@@ -4453,6 +4453,13 @@ class EzdxfBackend(AutoCADBackend):
|
||||
}
|
||||
if layer:
|
||||
attribs["layer"] = layer
|
||||
# `add_blockref` never checks the name, and `add_auto_attribs`
|
||||
# silently skips autofill when `Insert.block()` resolves to None,
|
||||
# so a typo'd name used to yield a dangling INSERT that dropped its
|
||||
# attribute values and that `doc.audit()` later deletes. Refuse
|
||||
# before writing, as COM's `InsertBlock` does for an unknown name.
|
||||
if name not in self._doc.blocks:
|
||||
raise ValueError(f"block {name!r} is not defined")
|
||||
ref = msp.add_blockref(name, (float(x), float(y)), dxfattribs=attribs)
|
||||
if attributes:
|
||||
# `add_auto_blockref` wraps the INSERT in an anonymous *U block,
|
||||
|
||||
Reference in New Issue
Block a user