overview
本文回答:选择 = ① 静态 API(
Engine.ssGetFirst / ssSetFirst / getEntities / getEntitiesByType);② 交互 API(getSelections / getEntity,详见 input/get-selections / input/get-entity);③ 高亮配套(Engine.highLightEntities / clearHighLight)。
一、按子主题挑
| 想做的 | 子主题 |
|---|---|
| 全部静态选择 / 过滤 / 设置选择集 API | selection-api |
| 交互式选择(弹出"选择对象:") | input/get-selections |
| 单实体拾取 | input/get-entity |
| 高亮 / 清除高亮 | edit/highlight |
二、心智模型
[图纸]
│
├─ Engine.getEntities() 所有实体
├─ Engine.getEntitiesByType('LINE') 按 type
├─ Engine.getEntities(e=>e.layer===name) 按图层(无 getEntitiesByLayer)
├─ Engine.getEntities(filter) 函数过滤
│
├─ Engine.ssGetFirst() 当前选择集
└─ Engine.ssSetFirst([...]) 设置当前选择集
三、最快入门
// 1. 取所有 LINE
const lines = Engine.getEntitiesByType('LINE');
console.log('LINE:', lines.length);
// 2. 把它们设为选择集(夹点 / 属性面板会反映)
Engine.ssSetFirst(lines);
// 3. 取当前选择
const sel = Engine.ssGetFirst();
console.log('selected:', sel.length);
// 4. 清空选择
Engine.ssSetFirst([]);
MCP 参考:vjcad/example/selection/01setselection.js、vjcad/example/selection/03getbytype.js。
参考(官方文档 MCP)
- 文档:
vjcad/doc/selection/index.md、vjcad/doc/selection/entity-selection.md - 示例:
vjcad/example/selection/01setselection.js~04getbyfilter.js