fix(com): create linear dimensions with AddDimRotated (#3)
dimension_linear always failed with '<unknown>.AddDimLinear' on the COM backend — pywin32's dynamic dispatch error for a method that does not exist: the AutoCAD ActiveX API has no AddDimLinear. AddDimRotated takes the same arguments (XLine1Point, XLine2Point, DimLineLocation, RotationAngle), so the call site only changes the method name. Adds a mocked regression test asserting AddDimRotated is called with the exact point/rotation arguments and AddDimLinear never is. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
d0dfa8cf2d
commit
3a0519724b
@@ -15,6 +15,10 @@ _Next: closed-loop refiner (critique→repair→re-critique with transaction-sta
|
||||
matching the project name, so hatchling could not infer which files to ship.
|
||||
`pyproject.toml` now declares the wheel file selection explicitly
|
||||
(`server.py`, `config.py`, `security.py`, `backends/`, `engineering/`). (#2)
|
||||
- **`dimension_linear` on the COM backend** — always crashed with
|
||||
`<unknown>.AddDimLinear`: the AutoCAD ActiveX API has no `AddDimLinear`
|
||||
method. Linear dimensions are now created via `AddDimRotated` (identical
|
||||
argument order), with a mocked regression test. (#3)
|
||||
|
||||
## [1.2.0] — 2026-07-07
|
||||
|
||||
|
||||
@@ -824,7 +824,9 @@ class ComBackend(AutoCADBackend):
|
||||
) -> EntityInfo:
|
||||
def _sync():
|
||||
mspace = _msp()
|
||||
dim = mspace.AddDimLinear(
|
||||
# The ActiveX API has no AddDimLinear — rotated linear dims are
|
||||
# created with AddDimRotated (GH issue #3).
|
||||
dim = mspace.AddDimRotated(
|
||||
_apoint(x1, y1), _apoint(x2, y2),
|
||||
_apoint(dim_x, dim_y), deg2rad(rotation),
|
||||
)
|
||||
|
||||
@@ -211,6 +211,42 @@ def test_safe_send_command_new_handle_detection():
|
||||
assert set(result) == {"1C", "1D"}
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# dimension_linear — must use AddDimRotated (GH issue #3)
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_dimension_linear_uses_add_dim_rotated():
|
||||
"""Regression for GH issue #3: the AutoCAD ActiveX API has no AddDimLinear
|
||||
method — calling it raised ``<unknown>.AddDimLinear``. Linear dimensions
|
||||
must go through AddDimRotated."""
|
||||
backend = ComBackend()
|
||||
|
||||
async def _run_inline(func, *args, **kwargs):
|
||||
return func(*args, **kwargs)
|
||||
|
||||
backend._run = _run_inline # bypass the COM executor thread
|
||||
|
||||
mspace = MagicMock()
|
||||
with (
|
||||
patch("backends.com_backend._msp", return_value=mspace),
|
||||
patch("backends.com_backend._apoint", side_effect=lambda *a: tuple(float(v) for v in a)),
|
||||
patch("backends.com_backend._regen"),
|
||||
patch("backends.com_backend._apply_dim_tolerance"),
|
||||
patch("backends.com_backend._entity_info", side_effect=lambda e: e),
|
||||
):
|
||||
await backend.dimension_linear(0, 0, 100, 0, 50, 20, rotation=0.0)
|
||||
|
||||
mspace.AddDimRotated.assert_called_once()
|
||||
mspace.AddDimLinear.assert_not_called()
|
||||
args = mspace.AddDimRotated.call_args[0]
|
||||
assert args[0] == (0.0, 0.0) # ext line 1 origin
|
||||
assert args[1] == (100.0, 0.0) # ext line 2 origin
|
||||
assert args[2] == (50.0, 20.0) # dim line location
|
||||
assert args[3] == pytest.approx(0.0) # rotation in radians
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Live integration — skipped unless AutoCAD is reachable
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user