feat(selection): add selection_get — read live viewport pickfirst selection (#1)

New COM-only Entity Query tool that reads AutoCAD's implied ("pickfirst")
selection set and returns the selected entity handles + EntityInfo, so the AI
can scope work (e.g. dimension_auto) to exactly what the user picked in the
viewport instead of the whole drawing. Resolves #1 — the layer-juggling
workaround is no longer needed.

- backends/base.py: abstract selection_get() returning a status dict
- backends/com_backend.py: reads ActiveDocument.PickfirstSelectionSet, surfaces
  the PICKFIRST sysvar, handles the empty-selection case
- backends/ezdxf_backend.py: headless stub (ok=False, empty handles, same shape)
- server.py: @mcp.tool registration (readOnlyHint), SECTION 5 3 -> 4 tools
- README + CHANGELOG + pyproject: 110 -> 111 tools, v1.1.0 -> v1.1.1

Verified live on AutoCAD 2027 (COM): selection_get correctly returned the
user's grip selection across two distinct picks; 318 tests pass, ruff-clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Umutcan Edizsalan
2026-06-20 11:41:36 +03:00
co-authored by Claude Opus 4.8
parent 5583730a79
commit dfb21a734a
7 changed files with 151 additions and 7 deletions
+14
View File
@@ -9,6 +9,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
_Next: 1.2 — closed-loop validation moat (scalar drawing-score, pre-plan clarification, iterative refiner + transaction-stack isolation)._
## [1.1.1] — 2026-06-20
### Added
- **`selection_get`** (Entity Query, COM backend): reads AutoCAD's implied
("pickfirst") viewport selection — the entities the user highlighted with
grips before invoking the AI — and returns their handles + `EntityInfo`.
This lets the AI scope work to exactly what the user picked
(`dimension_auto(selection_get()["handles"])`) instead of acting on the whole
drawing. Resolves [#1](https://github.com/U-C4N/Autocad-MCP/issues/1) — the
layer-juggling workaround is no longer needed. Surfaces the `PICKFIRST` sysvar
state so an empty selection is self-explanatory. The ezdxf headless backend
has no viewport, so it returns `ok=False` with an empty handle list (same
shape, never raises). Tool count: 110 → 111.
## [1.1.0] — 2026-06-19
Correctness, cross-backend parity, and an **enforced** quality gate, landed across four audited