fix(task-10): $DIMBLK header carries the canonical arrowhead name; MLeaderStyle is authored on COM through the ACAD_MLEADERSTYLE dictionary
Two review findings, both root causes.
1. `_sync_header_to_dimstyle` copied the DIMSTYLE entry's ezdxf-internal
arrowhead spelling (OBLIQUE) into the DXF-facing $DIMBLK/$DIMBLK1/$DIMBLK2
header, so the saved file named a block it did not hold (the blocks are
_OBLIQUE / _DOT) and `system_get_variable("DIMBLK")` answered "OBLIQUE"
headlessly against "_OBLIQUE" on COM and in the same engine's own
`dimstyle_list` row. The header write now goes through
`reported_arrowhead` — the same read-side rule `_dimstyle_value` applies.
Pinned by header, `system_get_variable`, save/reopen (`ezdxf.readfile`
header equals the block the file holds) and the Restore-to-Standard
empty-string case in `test_builtin_arrowheads_render_save_and_report_one_spelling`.
2. The `mleaderstyle` capability refusal rested on a false engine boundary.
acax25enu.tlb (AutoCAD 2026) exposes IAcadMLeaderStyle with Name,
ArrowSize, LandingGap, TextHeight, TextStyle, ... — exactly what
`Dictionaries.Item("ACAD_MLEADERSTYLE").Item(i)` returns — and
IAcadDictionary.AddObject(keyword, "AcDbMLeaderStyle") creates one.
COM `mleaderstyle_list` now reads the four values off those objects
(`values_available: True`); COM `mleaderstyle_create` validates every value
(`validate_mleaderstyle`, shared with ezdxf), checks the clash and the text
style before AddObject, then writes the four properties. The contract
method is `@abstractmethod` again, the key is gone from both capability
maps, the fake ActiveX surface models the real call shape, and the spec
(§4.2, §8.1, §9) states the ActiveX route.
Live AutoCAD was not running on this machine (GetActiveObject: operation
unavailable; no acad.exe), so the COM route is type-library-verified and
fake-tested, not executed live — scripts/smoke_settings_com.py (Task 24)
owns that.
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
4d246b17b8
commit
e204f227b4
@@ -30,6 +30,7 @@ from engineering.standards.mleaderstyles import (
|
||||
MLEADER_KEYS,
|
||||
MLEADER_PRESETS,
|
||||
resolve_mleaderstyle,
|
||||
validate_mleaderstyle,
|
||||
)
|
||||
from engineering.standards.textstyles import TEXT_PRESETS, resolve_font, validate_textstyle
|
||||
|
||||
@@ -564,3 +565,28 @@ def test_resolve_mleaderstyle_applies_overrides():
|
||||
def test_resolve_mleaderstyle_refuses_by_name(preset, overrides, exc, fragment):
|
||||
with pytest.raises(exc, match=fragment):
|
||||
resolve_mleaderstyle(preset, overrides)
|
||||
|
||||
|
||||
def test_validate_mleaderstyle_types_the_four_keys_and_refuses_by_name():
|
||||
"""What both engines' ``mleaderstyle_create`` run before any write: a
|
||||
hand-built dict is held to the same rules as a preset override."""
|
||||
assert validate_mleaderstyle(resolve_mleaderstyle("iso")) == MLEADER_PRESETS["iso"]
|
||||
typed = validate_mleaderstyle(
|
||||
{"arrow_size": 3, "landing_gap": 0, "text_style": " arial ", "text_height": 2, "extra": 1}
|
||||
)
|
||||
assert typed == {
|
||||
"arrow_size": 3.0,
|
||||
"landing_gap": 0.0,
|
||||
"text_style": "arial",
|
||||
"text_height": 2.0,
|
||||
}
|
||||
with pytest.raises(ValueError, match=r"missing \['landing_gap', 'text_style', 'text_height'\]"):
|
||||
validate_mleaderstyle({"arrow_size": 2.5})
|
||||
with pytest.raises(ValueError, match="arrow_size"):
|
||||
validate_mleaderstyle({**MLEADER_PRESETS["iso"], "arrow_size": 0})
|
||||
with pytest.raises(ValueError, match="text_style"):
|
||||
validate_mleaderstyle({**MLEADER_PRESETS["iso"], "text_style": "a|b"})
|
||||
with pytest.raises(TypeError, match="text_height"):
|
||||
validate_mleaderstyle({**MLEADER_PRESETS["iso"], "text_height": "2.5"})
|
||||
with pytest.raises(TypeError, match="values"):
|
||||
validate_mleaderstyle(["arrow_size"])
|
||||
|
||||
Reference in New Issue
Block a user