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:
co-authored by
Claude Opus 4.8
parent
5583730a79
commit
dfb21a734a
@@ -1466,6 +1466,19 @@ class EzdxfBackend(AutoCADBackend):
|
||||
]
|
||||
return await self._async(_sync)
|
||||
|
||||
async def selection_get(self) -> dict:
|
||||
# COM-only: headless ezdxf has no viewport / pickfirst grip selection.
|
||||
# Return a not-supported result but keep the same shape (empty handles)
|
||||
# so callers that iterate the selection do not KeyError.
|
||||
return {
|
||||
"ok": False,
|
||||
"error": "selection_get not supported in ezdxf backend (no live AutoCAD viewport)",
|
||||
"count": 0,
|
||||
"handles": [],
|
||||
"entities": [],
|
||||
"pickfirst": None,
|
||||
}
|
||||
|
||||
# ── view / screenshot ──────────────────────────────────────────────────────
|
||||
|
||||
async def view_zoom_extents(self) -> dict:
|
||||
|
||||
Reference in New Issue
Block a user