fix(blocks): block_define refuses a non-finite base point and a missing layer unless create_layers
base_x/base_y were only float()-cast, so a NaN base point was written into the BLOCK record; a primitive on a layer the drawing lacks was written as a dangling reference doc.audit() never flags (and on COM would fail mid-loop after Blocks.Add). validate_base_point names the key; the layer table is probed before the first write and the missing names are refused, or created and reported as layers_created when create_layers=true (new optional kwarg, contract + both engines + tool). 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
7f79497928
commit
375c9f4c70
@@ -58,9 +58,19 @@ class BlockContract(ABC):
|
||||
base_x: float = 0.0,
|
||||
base_y: float = 0.0,
|
||||
overwrite: bool = False,
|
||||
create_layers: bool = False,
|
||||
) -> dict:
|
||||
"""Create (or with ``overwrite`` replace the contents of) a block
|
||||
definition from typed primitive specs and ATTDEF specs — see
|
||||
``backends/block_specs.py`` for the spec vocabulary. Returns
|
||||
``{ok, name, entity_count, attdef_count, replaced, backend}``."""
|
||||
``backends/block_specs.py`` for the spec vocabulary.
|
||||
|
||||
Refusals, all before any write: a malformed spec (``TypeError`` naming
|
||||
``entities[i]``/``attdefs[i]`` and the key), a non-finite or non-numeric
|
||||
``base_x``/``base_y`` (``TypeError`` naming it), a name clash without
|
||||
``overwrite`` (``ValueError``), and a primitive ``layer`` that does not
|
||||
exist in the drawing (``ValueError`` listing the missing names) unless
|
||||
``create_layers`` is true, in which case the missing layers are created
|
||||
with the engine's defaults and listed in ``layers_created``. Returns
|
||||
``{ok, name, entity_count, attdef_count, replaced, layers_created,
|
||||
backend}``."""
|
||||
...
|
||||
|
||||
Reference in New Issue
Block a user